@gbl-uzh/platform 0.4.13 → 0.4.14-beta.1
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 +22 -25
- package/dist/index.js +27 -4
- package/dist/nexus.js +26 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { PrismaClient } from '@prisma/client';
|
|
|
5
5
|
import { NextPageContext } from 'next';
|
|
6
6
|
import * as yup from 'yup';
|
|
7
7
|
import yup__default from 'yup';
|
|
8
|
+
import * as _prisma_client_runtime_library from '@prisma/client/runtime/library';
|
|
8
9
|
|
|
9
10
|
declare const logger: winston.Logger;
|
|
10
11
|
|
|
@@ -783,6 +784,24 @@ declare function getLearningElements(args: any, ctx: Context$1): Promise<({
|
|
|
783
784
|
createdAt: Date;
|
|
784
785
|
updatedAt: Date;
|
|
785
786
|
})[]>;
|
|
787
|
+
declare function mapAction({ ctx, gameId, activePeriodIx, activeSegmentIx, playerId, }: {
|
|
788
|
+
ctx: Context$1;
|
|
789
|
+
gameId: number;
|
|
790
|
+
activePeriodIx: number;
|
|
791
|
+
activeSegmentIx?: number;
|
|
792
|
+
playerId: string;
|
|
793
|
+
}): (action: any) => DB.Prisma.Prisma__PlayerActionClient<{
|
|
794
|
+
id: number;
|
|
795
|
+
type: string;
|
|
796
|
+
facts: DB.Prisma.JsonValue;
|
|
797
|
+
gameId: number;
|
|
798
|
+
playerId: string;
|
|
799
|
+
periodId: number;
|
|
800
|
+
periodIx: number;
|
|
801
|
+
segmentId: number | null;
|
|
802
|
+
segmentIx: number | null;
|
|
803
|
+
createdAt: Date;
|
|
804
|
+
}, never, _prisma_client_runtime_library.DefaultArgs>;
|
|
786
805
|
declare function computePeriodStartResults({ results, players, activePeriodIx, gameId, periodFacts }: {
|
|
787
806
|
results: any;
|
|
788
807
|
players: any;
|
|
@@ -837,6 +856,7 @@ declare const GameService_getGame: typeof getGame;
|
|
|
837
856
|
declare const GameService_getGameFromContext: typeof getGameFromContext;
|
|
838
857
|
declare const GameService_getGames: typeof getGames;
|
|
839
858
|
declare const GameService_getLearningElements: typeof getLearningElements;
|
|
859
|
+
declare const GameService_mapAction: typeof mapAction;
|
|
840
860
|
declare const GameService_updatePlayerData: typeof updatePlayerData;
|
|
841
861
|
declare namespace GameService {
|
|
842
862
|
export {
|
|
@@ -854,6 +874,7 @@ declare namespace GameService {
|
|
|
854
874
|
GameService_getGameFromContext as getGameFromContext,
|
|
855
875
|
GameService_getGames as getGames,
|
|
856
876
|
GameService_getLearningElements as getLearningElements,
|
|
877
|
+
GameService_mapAction as mapAction,
|
|
857
878
|
GameService_updatePlayerData as updatePlayerData,
|
|
858
879
|
};
|
|
859
880
|
}
|
|
@@ -867,31 +888,7 @@ interface PerformActionArgs<ActionTypes> {
|
|
|
867
888
|
actionType: ActionTypes;
|
|
868
889
|
facts: any;
|
|
869
890
|
}
|
|
870
|
-
declare function performAction<ActionTypes>(args: PerformActionArgs<ActionTypes>, ctx: Context, { reducers }: any): Promise<
|
|
871
|
-
period: {
|
|
872
|
-
id: number;
|
|
873
|
-
index: number;
|
|
874
|
-
facts: DB.Prisma.JsonValue;
|
|
875
|
-
activeSegmentIx: number;
|
|
876
|
-
activeSegmentId: number | null;
|
|
877
|
-
nextPeriodId: number | null;
|
|
878
|
-
gameId: number;
|
|
879
|
-
createdAt: Date;
|
|
880
|
-
updatedAt: Date;
|
|
881
|
-
};
|
|
882
|
-
} & {
|
|
883
|
-
id: number;
|
|
884
|
-
type: DB.$Enums.PlayerResultType;
|
|
885
|
-
facts: DB.Prisma.JsonValue;
|
|
886
|
-
playerId: string;
|
|
887
|
-
gameId: number;
|
|
888
|
-
periodId: number;
|
|
889
|
-
periodIx: number;
|
|
890
|
-
segmentId: number | null;
|
|
891
|
-
segmentIx: number | null;
|
|
892
|
-
createdAt: Date;
|
|
893
|
-
updatedAt: Date;
|
|
894
|
-
}) | null>;
|
|
891
|
+
declare function performAction<ActionTypes>(args: PerformActionArgs<ActionTypes>, ctx: Context, { reducers }: any): Promise<any>;
|
|
895
892
|
interface SaveDecisionsArgs {
|
|
896
893
|
decisionType: DB.PlayerDecisionType;
|
|
897
894
|
facts: any;
|
package/dist/index.js
CHANGED
|
@@ -376,6 +376,7 @@ __export(GameService_exports, {
|
|
|
376
376
|
getGameFromContext: () => getGameFromContext,
|
|
377
377
|
getGames: () => getGames,
|
|
378
378
|
getLearningElements: () => getLearningElements,
|
|
379
|
+
mapAction: () => mapAction,
|
|
379
380
|
updatePlayerData: () => updatePlayerData
|
|
380
381
|
});
|
|
381
382
|
var DB2 = __toESM(require("@prisma/client"));
|
|
@@ -1135,7 +1136,13 @@ async function getLearningElements(args, ctx) {
|
|
|
1135
1136
|
}
|
|
1136
1137
|
});
|
|
1137
1138
|
}
|
|
1138
|
-
function mapAction({
|
|
1139
|
+
function mapAction({
|
|
1140
|
+
ctx,
|
|
1141
|
+
gameId,
|
|
1142
|
+
activePeriodIx,
|
|
1143
|
+
activeSegmentIx,
|
|
1144
|
+
playerId
|
|
1145
|
+
}) {
|
|
1139
1146
|
return (action) => ctx.prisma.playerAction.create({
|
|
1140
1147
|
data: {
|
|
1141
1148
|
type: action.type,
|
|
@@ -1155,7 +1162,7 @@ function mapAction({ ctx, gameId, activePeriodIx, playerId }) {
|
|
|
1155
1162
|
}
|
|
1156
1163
|
}
|
|
1157
1164
|
},
|
|
1158
|
-
segmentIx: typeof action.segment === "number" ? action.segment : void 0,
|
|
1165
|
+
segmentIx: typeof action.segment === "number" ? action.segment : typeof activeSegmentIx === "number" ? activeSegmentIx : void 0,
|
|
1159
1166
|
segment: typeof action.segment === "number" ? {
|
|
1160
1167
|
connect: {
|
|
1161
1168
|
gameId_periodIx_index: {
|
|
@@ -1164,6 +1171,14 @@ function mapAction({ ctx, gameId, activePeriodIx, playerId }) {
|
|
|
1164
1171
|
index: action.segment
|
|
1165
1172
|
}
|
|
1166
1173
|
}
|
|
1174
|
+
} : typeof activeSegmentIx === "number" ? {
|
|
1175
|
+
connect: {
|
|
1176
|
+
gameId_periodIx_index: {
|
|
1177
|
+
gameId,
|
|
1178
|
+
periodIx: activePeriodIx,
|
|
1179
|
+
index: activeSegmentIx
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1167
1182
|
} : void 0
|
|
1168
1183
|
}
|
|
1169
1184
|
});
|
|
@@ -1536,7 +1551,7 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1536
1551
|
if (previousResult.game.status !== DB3.GameStatus.RUNNING) {
|
|
1537
1552
|
throw new Error("ACTIONS_NOT_ALLOWED");
|
|
1538
1553
|
}
|
|
1539
|
-
const { result, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
|
|
1554
|
+
const { result, actions, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
|
|
1540
1555
|
type: args.actionType,
|
|
1541
1556
|
payload: {
|
|
1542
1557
|
playerArgs: args.facts,
|
|
@@ -1544,6 +1559,13 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1544
1559
|
periodFacts: previousResult.period.facts
|
|
1545
1560
|
}
|
|
1546
1561
|
});
|
|
1562
|
+
const mapper = mapAction({
|
|
1563
|
+
ctx,
|
|
1564
|
+
gameId: args.gameId,
|
|
1565
|
+
activePeriodIx: args.periodIx,
|
|
1566
|
+
activeSegmentIx: args.segmentIx,
|
|
1567
|
+
playerId: args.playerId
|
|
1568
|
+
});
|
|
1547
1569
|
publishUserNotification(ctx, notifications);
|
|
1548
1570
|
await receiveEvents({
|
|
1549
1571
|
events,
|
|
@@ -1608,7 +1630,8 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1608
1630
|
...extras
|
|
1609
1631
|
}
|
|
1610
1632
|
}
|
|
1611
|
-
})
|
|
1633
|
+
}),
|
|
1634
|
+
...(actions ?? []).map(mapper)
|
|
1612
1635
|
]);
|
|
1613
1636
|
return updatedResult;
|
|
1614
1637
|
}
|
package/dist/nexus.js
CHANGED
|
@@ -1430,7 +1430,13 @@ async function getLearningElements(args, ctx) {
|
|
|
1430
1430
|
}
|
|
1431
1431
|
});
|
|
1432
1432
|
}
|
|
1433
|
-
function mapAction({
|
|
1433
|
+
function mapAction({
|
|
1434
|
+
ctx,
|
|
1435
|
+
gameId,
|
|
1436
|
+
activePeriodIx,
|
|
1437
|
+
activeSegmentIx,
|
|
1438
|
+
playerId
|
|
1439
|
+
}) {
|
|
1434
1440
|
return (action) => ctx.prisma.playerAction.create({
|
|
1435
1441
|
data: {
|
|
1436
1442
|
type: action.type,
|
|
@@ -1450,7 +1456,7 @@ function mapAction({ ctx, gameId, activePeriodIx, playerId }) {
|
|
|
1450
1456
|
}
|
|
1451
1457
|
}
|
|
1452
1458
|
},
|
|
1453
|
-
segmentIx: typeof action.segment === "number" ? action.segment : void 0,
|
|
1459
|
+
segmentIx: typeof action.segment === "number" ? action.segment : typeof activeSegmentIx === "number" ? activeSegmentIx : void 0,
|
|
1454
1460
|
segment: typeof action.segment === "number" ? {
|
|
1455
1461
|
connect: {
|
|
1456
1462
|
gameId_periodIx_index: {
|
|
@@ -1459,6 +1465,14 @@ function mapAction({ ctx, gameId, activePeriodIx, playerId }) {
|
|
|
1459
1465
|
index: action.segment
|
|
1460
1466
|
}
|
|
1461
1467
|
}
|
|
1468
|
+
} : typeof activeSegmentIx === "number" ? {
|
|
1469
|
+
connect: {
|
|
1470
|
+
gameId_periodIx_index: {
|
|
1471
|
+
gameId,
|
|
1472
|
+
periodIx: activePeriodIx,
|
|
1473
|
+
index: activeSegmentIx
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1462
1476
|
} : void 0
|
|
1463
1477
|
}
|
|
1464
1478
|
});
|
|
@@ -1816,7 +1830,7 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1816
1830
|
if (previousResult.game.status !== DB7.GameStatus.RUNNING) {
|
|
1817
1831
|
throw new Error("ACTIONS_NOT_ALLOWED");
|
|
1818
1832
|
}
|
|
1819
|
-
const { result, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
|
|
1833
|
+
const { result, actions, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
|
|
1820
1834
|
type: args.actionType,
|
|
1821
1835
|
payload: {
|
|
1822
1836
|
playerArgs: args.facts,
|
|
@@ -1824,6 +1838,13 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1824
1838
|
periodFacts: previousResult.period.facts
|
|
1825
1839
|
}
|
|
1826
1840
|
});
|
|
1841
|
+
const mapper = mapAction({
|
|
1842
|
+
ctx,
|
|
1843
|
+
gameId: args.gameId,
|
|
1844
|
+
activePeriodIx: args.periodIx,
|
|
1845
|
+
activeSegmentIx: args.segmentIx,
|
|
1846
|
+
playerId: args.playerId
|
|
1847
|
+
});
|
|
1827
1848
|
publishUserNotification(ctx, notifications);
|
|
1828
1849
|
await receiveEvents({
|
|
1829
1850
|
events,
|
|
@@ -1888,7 +1909,8 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1888
1909
|
...extras
|
|
1889
1910
|
}
|
|
1890
1911
|
}
|
|
1891
|
-
})
|
|
1912
|
+
}),
|
|
1913
|
+
...(actions ?? []).map(mapper)
|
|
1892
1914
|
]);
|
|
1893
1915
|
return updatedResult;
|
|
1894
1916
|
}
|