@gbl-uzh/platform 0.4.13 → 0.4.14-beta.0

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
@@ -783,6 +783,12 @@ declare function getLearningElements(args: any, ctx: Context$1): Promise<({
783
783
  createdAt: Date;
784
784
  updatedAt: Date;
785
785
  })[]>;
786
+ declare function mapAction({ ctx, gameId, activePeriodIx, playerId }: {
787
+ ctx: any;
788
+ gameId: any;
789
+ activePeriodIx: any;
790
+ playerId: any;
791
+ }): (action: any) => any;
786
792
  declare function computePeriodStartResults({ results, players, activePeriodIx, gameId, periodFacts }: {
787
793
  results: any;
788
794
  players: any;
@@ -837,6 +843,7 @@ declare const GameService_getGame: typeof getGame;
837
843
  declare const GameService_getGameFromContext: typeof getGameFromContext;
838
844
  declare const GameService_getGames: typeof getGames;
839
845
  declare const GameService_getLearningElements: typeof getLearningElements;
846
+ declare const GameService_mapAction: typeof mapAction;
840
847
  declare const GameService_updatePlayerData: typeof updatePlayerData;
841
848
  declare namespace GameService {
842
849
  export {
@@ -854,6 +861,7 @@ declare namespace GameService {
854
861
  GameService_getGameFromContext as getGameFromContext,
855
862
  GameService_getGames as getGames,
856
863
  GameService_getLearningElements as getLearningElements,
864
+ GameService_mapAction as mapAction,
857
865
  GameService_updatePlayerData as updatePlayerData,
858
866
  };
859
867
  }
@@ -867,31 +875,7 @@ interface PerformActionArgs<ActionTypes> {
867
875
  actionType: ActionTypes;
868
876
  facts: any;
869
877
  }
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>;
878
+ declare function performAction<ActionTypes>(args: PerformActionArgs<ActionTypes>, ctx: Context, { reducers }: any): Promise<any>;
895
879
  interface SaveDecisionsArgs {
896
880
  decisionType: DB.PlayerDecisionType;
897
881
  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"));
@@ -1536,7 +1537,7 @@ async function performAction(args, ctx, { reducers }) {
1536
1537
  if (previousResult.game.status !== DB3.GameStatus.RUNNING) {
1537
1538
  throw new Error("ACTIONS_NOT_ALLOWED");
1538
1539
  }
1539
- const { result, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
1540
+ const { result, actions, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
1540
1541
  type: args.actionType,
1541
1542
  payload: {
1542
1543
  playerArgs: args.facts,
@@ -1544,6 +1545,12 @@ async function performAction(args, ctx, { reducers }) {
1544
1545
  periodFacts: previousResult.period.facts
1545
1546
  }
1546
1547
  });
1548
+ const mapper = mapAction({
1549
+ ctx,
1550
+ gameId: args.gameId,
1551
+ activePeriodIx: args.periodIx,
1552
+ playerId: args.playerId
1553
+ });
1547
1554
  publishUserNotification(ctx, notifications);
1548
1555
  await receiveEvents({
1549
1556
  events,
@@ -1608,7 +1615,8 @@ async function performAction(args, ctx, { reducers }) {
1608
1615
  ...extras
1609
1616
  }
1610
1617
  }
1611
- })
1618
+ }),
1619
+ ...(actions ?? []).map(mapper)
1612
1620
  ]);
1613
1621
  return updatedResult;
1614
1622
  }
package/dist/nexus.js CHANGED
@@ -1816,7 +1816,7 @@ async function performAction(args, ctx, { reducers }) {
1816
1816
  if (previousResult.game.status !== DB7.GameStatus.RUNNING) {
1817
1817
  throw new Error("ACTIONS_NOT_ALLOWED");
1818
1818
  }
1819
- const { result, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
1819
+ const { result, actions, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
1820
1820
  type: args.actionType,
1821
1821
  payload: {
1822
1822
  playerArgs: args.facts,
@@ -1824,6 +1824,12 @@ async function performAction(args, ctx, { reducers }) {
1824
1824
  periodFacts: previousResult.period.facts
1825
1825
  }
1826
1826
  });
1827
+ const mapper = mapAction({
1828
+ ctx,
1829
+ gameId: args.gameId,
1830
+ activePeriodIx: args.periodIx,
1831
+ playerId: args.playerId
1832
+ });
1827
1833
  publishUserNotification(ctx, notifications);
1828
1834
  await receiveEvents({
1829
1835
  events,
@@ -1888,7 +1894,8 @@ async function performAction(args, ctx, { reducers }) {
1888
1894
  ...extras
1889
1895
  }
1890
1896
  }
1891
- })
1897
+ }),
1898
+ ...(actions ?? []).map(mapper)
1892
1899
  ]);
1893
1900
  return updatedResult;
1894
1901
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gbl-uzh/platform",
3
- "version": "0.4.13",
3
+ "version": "0.4.14-beta.0",
4
4
  "license": "LGPL-3.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",