@gbl-uzh/platform 0.4.25 → 0.4.26
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/lib/SSELink.d.ts.map +1 -1
- package/dist/lib/SSELink.js +3 -2
- package/dist/lib/SSELink.js.map +1 -1
- package/dist/lib/pubsub.d.ts +2 -1
- package/dist/lib/pubsub.d.ts.map +1 -1
- package/dist/lib/pubsub.js.map +1 -1
- package/dist/nexus.d.ts.map +1 -1
- package/dist/nexus.js +2 -0
- package/dist/nexus.js.map +1 -1
- package/dist/ops/SGlobalEvents.graphql +2 -0
- package/dist/services/AccountService.d.ts.map +1 -1
- package/dist/services/AccountService.js +4 -8
- package/dist/services/AccountService.js.map +1 -1
- package/dist/services/EventService.d.ts +2 -1
- package/dist/services/EventService.d.ts.map +1 -1
- package/dist/services/EventService.js +8 -2
- package/dist/services/EventService.js.map +1 -1
- package/dist/services/GameService.d.ts +2 -213
- package/dist/services/GameService.d.ts.map +1 -1
- package/dist/services/GameService.js +73 -14
- package/dist/services/GameService.js.map +1 -1
- package/dist/services/PlayService.d.ts.map +1 -1
- package/dist/services/PlayService.js +24 -5
- package/dist/services/PlayService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/Subscription.d.ts.map +1 -1
- package/dist/types/Subscription.js +10 -2
- package/dist/types/Subscription.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SSELink.d.ts","sourceRoot":"","sources":["../../src/lib/SSELink.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAU,aAAa,EAAgB,MAAM,aAAa,CAAA;AAEjE,cAAM,OAAQ,SAAQ,UAAU;IAC9B,OAAO,CAAC,MAAM,CAAQ;gBAEV,OAAO,EAAE,aAAa;IAKlB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"SSELink.d.ts","sourceRoot":"","sources":["../../src/lib/SSELink.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAU,aAAa,EAAgB,MAAM,aAAa,CAAA;AAEjE,cAAM,OAAQ,SAAQ,UAAU;IAC9B,OAAO,CAAC,MAAM,CAAQ;gBAEV,OAAO,EAAE,aAAa;IAKlB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC;CAmBvE;AAED,eAAe,OAAO,CAAA"}
|
package/dist/lib/SSELink.js
CHANGED
|
@@ -16,8 +16,9 @@ class SSELink extends ApolloLink {
|
|
|
16
16
|
if (value.errors) {
|
|
17
17
|
sink.error(value.errors);
|
|
18
18
|
}
|
|
19
|
-
else
|
|
20
|
-
sink.next(
|
|
19
|
+
else {
|
|
20
|
+
// Ensure `sink.next()` always receives a full FetchResult object
|
|
21
|
+
sink.next(value);
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
complete: sink.complete.bind(sink),
|
package/dist/lib/SSELink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SSELink.js","sources":["../../src/lib/SSELink.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;AAWA,MAAM,OAAQ,SAAQ,UAAU,CAAA;AACtB,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,OAAsB,EAAA;AAChC,QAAA,KAAK,EAAE;AACP,QAAA,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC;;AAGrB,IAAA,OAAO,CAAC,SAAoB,EAAA;AAC1C,QAAA,OAAO,IAAI,UAAU,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pubsub.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { BaseGlobalNotificationType, Event as PlatformEvent } from '../types.js';
|
|
1
2
|
export declare const pubSub: import("node_modules/graphql-yoga/typings/index.cjs").PubSub<{
|
|
2
|
-
'global:events': [event:
|
|
3
|
+
'global:events': [event: PlatformEvent<BaseGlobalNotificationType>];
|
|
3
4
|
'user:events': [userId: string, events: any];
|
|
4
5
|
}>;
|
|
5
6
|
//# sourceMappingURL=pubsub.d.ts.map
|
package/dist/lib/pubsub.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pubsub.d.ts","sourceRoot":"","sources":["../../src/lib/pubsub.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pubsub.d.ts","sourceRoot":"","sources":["../../src/lib/pubsub.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,0BAA0B,EAC1B,KAAK,IAAI,aAAa,EACvB,MAAM,aAAa,CAAA;AAEpB,eAAO,MAAM,MAAM;qBACA,CAAC,KAAK,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAAC;mBACpD,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC;EAC1C,CAAA"}
|
package/dist/lib/pubsub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pubsub.js","sources":["../../src/lib/pubsub.ts"],"sourcesContent":[null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"pubsub.js","sources":["../../src/lib/pubsub.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAMa,MAAA,MAAM,GAAG,YAAY;;;;"}
|
package/dist/nexus.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../src/nexus.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,qDAA4C,CAAA;AACnE,eAAO,MAAM,UAAU,qDAA0C,CAAA;AAEjE,eAAO,MAAM,QAAQ,2DAGnB,CAAA;AAEF,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../src/nexus.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,qDAA4C,CAAA;AACnE,eAAO,MAAM,UAAU,qDAA0C,CAAA;AAEjE,eAAO,MAAM,QAAQ,2DAGnB,CAAA;AAEF,eAAO,MAAM,KAAK,0DAOhB,CAAA;AAEF,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA"}
|
package/dist/nexus.js
CHANGED
package/dist/nexus.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.js","sources":["../src/nexus.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAIa,MAAA,UAAU,GAAG,aAAa,CAAC,kBAAkB,EAAE,MAAM;AACrD,MAAA,UAAU,GAAG,aAAa,CAAC,gBAAgB,EAAE,MAAM;AAEzD,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAC/B,IAAA,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC;AACpC,CAAA;AAEM,MAAM,KAAK,GAAG,UAAU,CAAC;AAC9B,IAAA,IAAI,EAAE,OAAO;AACb,IAAA,UAAU,CAAC,CAAC,EAAA;AACV,QAAA,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"nexus.js","sources":["../src/nexus.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAIa,MAAA,UAAU,GAAG,aAAa,CAAC,kBAAkB,EAAE,MAAM;AACrD,MAAA,UAAU,GAAG,aAAa,CAAC,gBAAgB,EAAE,MAAM;AAEzD,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAC/B,IAAA,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC;AACpC,CAAA;AAEM,MAAM,KAAK,GAAG,UAAU,CAAC;AAC9B,IAAA,IAAI,EAAE,OAAO;AACb,IAAA,UAAU,CAAC,CAAC,EAAA;AACV,QAAA,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AAChB,QAAA,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACf,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;KACzC;AACF,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountService.d.ts","sourceRoot":"","sources":["../../src/services/AccountService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAErD,UAAU,oBAAoB;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,GAAG,EACH,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,oBAAoB,UAQtB;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,WAAW,CAC/B,EAAE,KAAK,EAAE,EAAE,eAAe,EAC1B,GAAG,EAAE,aAAa,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"AccountService.d.ts","sourceRoot":"","sources":["../../src/services/AccountService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAErD,UAAU,oBAAoB;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,GAAG,EACH,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,oBAAoB,UAQtB;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,WAAW,CAC/B,EAAE,KAAK,EAAE,EAAE,eAAe,EAC1B,GAAG,EAAE,aAAa,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA6CjC;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,aAAa,CAAC,YAAY,CAAC,oBAkBlE"}
|
|
@@ -37,14 +37,12 @@ async function loginAsTeam({ token }, ctx) {
|
|
|
37
37
|
role: UserRole.PLAYER,
|
|
38
38
|
token: matchingPlayer.token,
|
|
39
39
|
});
|
|
40
|
-
const cookieName =
|
|
41
|
-
? '__Secure-next-auth.session-token'
|
|
42
|
-
: 'next-auth.session-token';
|
|
40
|
+
const cookieName = '__Secure-next-auth.session-token';
|
|
43
41
|
setCookie(ctx, cookieName, jwt, {
|
|
44
42
|
path: '/',
|
|
45
43
|
maxAge: 60 * 60 * 24 * 7,
|
|
46
|
-
httpOnly:
|
|
47
|
-
secure:
|
|
44
|
+
httpOnly: true,
|
|
45
|
+
secure: true,
|
|
48
46
|
});
|
|
49
47
|
}
|
|
50
48
|
catch (err) {
|
|
@@ -62,9 +60,7 @@ async function logoutAsTeam(ctx) {
|
|
|
62
60
|
},
|
|
63
61
|
});
|
|
64
62
|
if (matchingPlayer) {
|
|
65
|
-
const cookieName =
|
|
66
|
-
? '__Secure-next-auth.session-token'
|
|
67
|
-
: 'next-auth.session-token';
|
|
63
|
+
const cookieName = '__Secure-next-auth.session-token';
|
|
68
64
|
destroyCookie(ctx, cookieName);
|
|
69
65
|
return true;
|
|
70
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountService.js","sources":["../../src/services/AccountService.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAYM,SAAU,gBAAgB,CAAC,EAC/B,GAAG,EACH,IAAI,EACJ,GAAG,KAAK,EACa,EAAA;AACrB,IAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;AAChC,QAAA,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC;;AAG/C,IAAA,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;AACpE,QAAA,SAAS,EAAE,QAAQ;AACpB,KAAA,CAAC;AACJ;AAMO,eAAe,WAAW,CAC/B,EAAE,KAAK,EAAmB,EAC1B,GAAgC,EAAA;IAEhC,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;QACxD,KAAK,EAAE,EAAE,KAAK,EAAE;AAChB,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE;AACJ,gBAAA,OAAO,EAAE;AACP,oBAAA,YAAY,EAAE,IAAI;AACnB,iBAAA;AACF,aAAA;AACD,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,YAAY,EAAE;AACZ,gBAAA,OAAO,EAAE;AACP,oBAAA,WAAW,EAAE,IAAI;AAClB,iBAAA;AACF,aAAA;AACF,SAAA;AACF,KAAA,CAAC;IAEF,IAAI,CAAC,cAAc,EAAE;AACnB,QAAA,MAAM,IAAI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iveEvents({ events, ctx, prisma }: {
|
|
2
3
|
events: any;
|
|
3
4
|
ctx: any;
|
|
4
5
|
prisma: any;
|
|
5
6
|
}): Promise<any>;
|
|
6
7
|
export declare function receiveEvent(event: any, definedEvents: any, definedLevels: any, prisma: any): Promise<any[]>;
|
|
7
|
-
export declare function publishGlobalNotification(event:
|
|
8
|
+
export declare function publishGlobalNotification(event: PlatformEvent<BaseGlobalNotificationType>): void;
|
|
8
9
|
export declare function publishUserNotification(ctx: {
|
|
9
10
|
user: {
|
|
10
11
|
sub: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventService.d.ts","sourceRoot":"","sources":["../../src/services/EventService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EventService.d.ts","sourceRoot":"","sources":["../../src/services/EventService.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,0BAA0B,EAC1B,KAAK,IAAI,aAAa,EACvB,MAAM,aAAa,CAAA;AAGpB,wBAAsB,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;;;;CAAA,gBAoB1D;AAkBD,wBAAsB,YAAY,CAChC,KAAK,KAAA,EACL,aAAa,KAAA,EACb,aAAa,KAAA,EACb,MAAM,KAAA,kBA0KP;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,aAAa,CAAC,0BAA0B,CAAC,QAQjD;AAED,wBAAgB,uBAAuB,CACrC,GAAG,EAAE;IAAE,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAC9B,MAAM,CAAC,EAAE,GAAG,QAMb"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as DB from '@prisma/client';
|
|
2
2
|
import { pubSub } from '../lib/pubsub.js';
|
|
3
3
|
import { BaseUserNotificationType } from '../types.js';
|
|
4
|
+
import logger from '../lib/logger.js';
|
|
4
5
|
|
|
5
6
|
async function receiveEvents({ events, ctx, prisma }) {
|
|
6
7
|
if (!Array.isArray(events))
|
|
@@ -166,8 +167,13 @@ async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
|
166
167
|
return [];
|
|
167
168
|
}
|
|
168
169
|
function publishGlobalNotification(event) {
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
try {
|
|
171
|
+
pubSub.publish('global:events', event);
|
|
172
|
+
logger.info('[EventService] Successfully published to "global:events".');
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
logger.error('[EventService] Error during pubSub.publish:', e);
|
|
176
|
+
}
|
|
171
177
|
}
|
|
172
178
|
function publishUserNotification(ctx, events) {
|
|
173
179
|
if (events && events.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventService.js","sources":["../../src/services/EventService.ts"],"sourcesContent":[null],"names":["UserNotificationType"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EventService.js","sources":["../../src/services/EventService.ts"],"sourcesContent":[null],"names":["UserNotificationType","log"],"mappings":";;;;;AASO,eAAe,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAA;AACzD,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE;IAE5B,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAChD,QAAA,OAAO,EAAE;AACP,YAAA,YAAY,EAAE,IAAI;AACnB,SAAA;AACF,KAAA,CAAC;IAEF,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAEzD,IAAA,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,MAAM,CAAC,GAAG,CAAC,OAAO,KAAK,KACrB,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,CACtE,CACF;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC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AE;gCACf,IAAI,EAAE,mBAAmB,CAAC,eAAe;AAC1C,6BAAA;AACF,yBAAA;qBACF,CAAC;iBACH;;;AAIL,QAAA,OAAO,EAAE;;AAGX,IAAA,OAAO,EAAE;AACX;AAEM,SAAU,yBAAyB,CACvC,KAAgD,EAAA;AAEhD,IAAA,IAAI;AACF,QAAA,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC;AACtC,QAAAC,MAAG,CAAC,IAAI,CAAC,2DAA2D,CAAC;;IACrE,OAAO,CAAC,EAAE;AACV,QAAAA,MAAG,CAAC,KAAK,CAAC,6CAA6C,EAAE,CAAC,CAAC;;AAE/D;AAEgB,SAAA,uBAAuB,CACrC,GAA8B,EAC9B,MAAY,EAAA;IAEZ,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;;AAE/B,QAAA,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,MAAa,CAAC;;AAE9D;;;;"}
|
|
@@ -151,222 +151,11 @@ export declare function addPeriodSegment<TFacts>({ gameId, periodIx, facts, lear
|
|
|
151
151
|
interface ActivateNextPeriodArgs {
|
|
152
152
|
gameId: number;
|
|
153
153
|
}
|
|
154
|
-
export declare function activateNextPeriod({ gameId }: ActivateNextPeriodArgs, ctx: Context, { services }: CtxWithFacts<any, PrismaClient>): Promise<
|
|
155
|
-
periods: ({
|
|
156
|
-
segments: {
|
|
157
|
-
gameId: number;
|
|
158
|
-
id: number;
|
|
159
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
160
|
-
createdAt: Date;
|
|
161
|
-
updatedAt: Date;
|
|
162
|
-
index: number;
|
|
163
|
-
periodId: number;
|
|
164
|
-
periodIx: number;
|
|
165
|
-
countdownExpiresAt: Date | null;
|
|
166
|
-
countdownDurationMs: number | null;
|
|
167
|
-
nextSegmentId: number | null;
|
|
168
|
-
}[];
|
|
169
|
-
} & {
|
|
170
|
-
gameId: number;
|
|
171
|
-
id: number;
|
|
172
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
173
|
-
createdAt: Date;
|
|
174
|
-
updatedAt: Date;
|
|
175
|
-
index: number;
|
|
176
|
-
segmentCount: number;
|
|
177
|
-
activeSegmentIx: number;
|
|
178
|
-
activeSegmentId: number | null;
|
|
179
|
-
nextPeriodId: number | null;
|
|
180
|
-
})[];
|
|
181
|
-
} & {
|
|
182
|
-
id: number;
|
|
183
|
-
name: string;
|
|
184
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
185
|
-
createdAt: Date;
|
|
186
|
-
updatedAt: Date;
|
|
187
|
-
status: DB.$Enums.GameStatus;
|
|
188
|
-
activePeriodIx: number;
|
|
189
|
-
activePeriodId: number | null;
|
|
190
|
-
ownerId: string;
|
|
191
|
-
}, {
|
|
192
|
-
gameId: number;
|
|
193
|
-
id: number;
|
|
194
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
195
|
-
createdAt: Date;
|
|
196
|
-
updatedAt: Date;
|
|
197
|
-
index: number;
|
|
198
|
-
segmentCount: number;
|
|
199
|
-
activeSegmentIx: number;
|
|
200
|
-
activeSegmentId: number | null;
|
|
201
|
-
nextPeriodId: number | null;
|
|
202
|
-
}, ...any[]] | null>;
|
|
154
|
+
export declare function activateNextPeriod({ gameId }: ActivateNextPeriodArgs, ctx: Context, { services }: CtxWithFacts<any, PrismaClient>): Promise<any>;
|
|
203
155
|
interface ActivateSegmentArgs {
|
|
204
156
|
gameId: number;
|
|
205
157
|
}
|
|
206
|
-
export declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Context, { services }: CtxWithFacts<any, PrismaClient>): Promise<
|
|
207
|
-
players: {
|
|
208
|
-
number: number;
|
|
209
|
-
role: string | null;
|
|
210
|
-
token: string;
|
|
211
|
-
gameId: number;
|
|
212
|
-
id: string;
|
|
213
|
-
name: string;
|
|
214
|
-
isReady: boolean;
|
|
215
|
-
experience: number;
|
|
216
|
-
experienceToNext: number;
|
|
217
|
-
levelIx: number;
|
|
218
|
-
tutorialCompleted: boolean;
|
|
219
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
220
|
-
achievementKeys: string[];
|
|
221
|
-
achievementIds: string[];
|
|
222
|
-
completedLearningElementIds: string[];
|
|
223
|
-
visitedStoryElementIds: string[];
|
|
224
|
-
createdAt: Date;
|
|
225
|
-
updatedAt: Date;
|
|
226
|
-
}[];
|
|
227
|
-
periods: ({
|
|
228
|
-
segments: {
|
|
229
|
-
gameId: number;
|
|
230
|
-
id: number;
|
|
231
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
232
|
-
createdAt: Date;
|
|
233
|
-
updatedAt: Date;
|
|
234
|
-
index: number;
|
|
235
|
-
periodId: number;
|
|
236
|
-
periodIx: number;
|
|
237
|
-
countdownExpiresAt: Date | null;
|
|
238
|
-
countdownDurationMs: number | null;
|
|
239
|
-
nextSegmentId: number | null;
|
|
240
|
-
}[];
|
|
241
|
-
} & {
|
|
242
|
-
gameId: number;
|
|
243
|
-
id: number;
|
|
244
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
245
|
-
createdAt: Date;
|
|
246
|
-
updatedAt: Date;
|
|
247
|
-
index: number;
|
|
248
|
-
segmentCount: number;
|
|
249
|
-
activeSegmentIx: number;
|
|
250
|
-
activeSegmentId: number | null;
|
|
251
|
-
nextPeriodId: number | null;
|
|
252
|
-
})[];
|
|
253
|
-
} & {
|
|
254
|
-
id: number;
|
|
255
|
-
name: string;
|
|
256
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
257
|
-
createdAt: Date;
|
|
258
|
-
updatedAt: Date;
|
|
259
|
-
status: DB.$Enums.GameStatus;
|
|
260
|
-
activePeriodIx: number;
|
|
261
|
-
activePeriodId: number | null;
|
|
262
|
-
ownerId: string;
|
|
263
|
-
}, {
|
|
264
|
-
gameId: number;
|
|
265
|
-
id: number;
|
|
266
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
267
|
-
createdAt: Date;
|
|
268
|
-
updatedAt: Date;
|
|
269
|
-
index: number;
|
|
270
|
-
segmentCount: number;
|
|
271
|
-
activeSegmentIx: number;
|
|
272
|
-
activeSegmentId: number | null;
|
|
273
|
-
nextPeriodId: number | null;
|
|
274
|
-
}, {
|
|
275
|
-
gameId: number;
|
|
276
|
-
id: number;
|
|
277
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
278
|
-
createdAt: Date;
|
|
279
|
-
updatedAt: Date;
|
|
280
|
-
index: number;
|
|
281
|
-
periodId: number;
|
|
282
|
-
periodIx: number;
|
|
283
|
-
countdownExpiresAt: Date | null;
|
|
284
|
-
countdownDurationMs: number | null;
|
|
285
|
-
nextSegmentId: number | null;
|
|
286
|
-
}, ...any[]] | [{
|
|
287
|
-
players: {
|
|
288
|
-
number: number;
|
|
289
|
-
role: string | null;
|
|
290
|
-
token: string;
|
|
291
|
-
gameId: number;
|
|
292
|
-
id: string;
|
|
293
|
-
name: string;
|
|
294
|
-
isReady: boolean;
|
|
295
|
-
experience: number;
|
|
296
|
-
experienceToNext: number;
|
|
297
|
-
levelIx: number;
|
|
298
|
-
tutorialCompleted: boolean;
|
|
299
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
300
|
-
achievementKeys: string[];
|
|
301
|
-
achievementIds: string[];
|
|
302
|
-
completedLearningElementIds: string[];
|
|
303
|
-
visitedStoryElementIds: string[];
|
|
304
|
-
createdAt: Date;
|
|
305
|
-
updatedAt: Date;
|
|
306
|
-
}[];
|
|
307
|
-
periods: ({
|
|
308
|
-
segments: {
|
|
309
|
-
gameId: number;
|
|
310
|
-
id: number;
|
|
311
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
312
|
-
createdAt: Date;
|
|
313
|
-
updatedAt: Date;
|
|
314
|
-
index: number;
|
|
315
|
-
periodId: number;
|
|
316
|
-
periodIx: number;
|
|
317
|
-
countdownExpiresAt: Date | null;
|
|
318
|
-
countdownDurationMs: number | null;
|
|
319
|
-
nextSegmentId: number | null;
|
|
320
|
-
}[];
|
|
321
|
-
} & {
|
|
322
|
-
gameId: number;
|
|
323
|
-
id: number;
|
|
324
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
325
|
-
createdAt: Date;
|
|
326
|
-
updatedAt: Date;
|
|
327
|
-
index: number;
|
|
328
|
-
segmentCount: number;
|
|
329
|
-
activeSegmentIx: number;
|
|
330
|
-
activeSegmentId: number | null;
|
|
331
|
-
nextPeriodId: number | null;
|
|
332
|
-
})[];
|
|
333
|
-
} & {
|
|
334
|
-
id: number;
|
|
335
|
-
name: string;
|
|
336
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
337
|
-
createdAt: Date;
|
|
338
|
-
updatedAt: Date;
|
|
339
|
-
status: DB.$Enums.GameStatus;
|
|
340
|
-
activePeriodIx: number;
|
|
341
|
-
activePeriodId: number | null;
|
|
342
|
-
ownerId: string;
|
|
343
|
-
}, {
|
|
344
|
-
results: {
|
|
345
|
-
gameId: number;
|
|
346
|
-
id: number;
|
|
347
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
348
|
-
createdAt: Date;
|
|
349
|
-
updatedAt: Date;
|
|
350
|
-
playerId: string;
|
|
351
|
-
periodId: number;
|
|
352
|
-
periodIx: number;
|
|
353
|
-
type: DB.$Enums.PlayerResultType;
|
|
354
|
-
segmentIx: number | null;
|
|
355
|
-
segmentId: number | null;
|
|
356
|
-
}[];
|
|
357
|
-
} & {
|
|
358
|
-
gameId: number;
|
|
359
|
-
id: number;
|
|
360
|
-
facts: import("@prisma/client/runtime/library").JsonValue;
|
|
361
|
-
createdAt: Date;
|
|
362
|
-
updatedAt: Date;
|
|
363
|
-
index: number;
|
|
364
|
-
periodId: number;
|
|
365
|
-
periodIx: number;
|
|
366
|
-
countdownExpiresAt: Date | null;
|
|
367
|
-
countdownDurationMs: number | null;
|
|
368
|
-
nextSegmentId: number | null;
|
|
369
|
-
}, DB.Prisma.BatchPayload, ...any[]] | null>;
|
|
158
|
+
export declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Context, { services }: CtxWithFacts<any, PrismaClient>): Promise<any>;
|
|
370
159
|
export declare function updatePlayerData<PlayerFactsType>({ name, facts }: UpdatePlayerDataArgs<PlayerFactsType>, ctx: Context, { schema }: {
|
|
371
160
|
schema: yup.Schema<PlayerFactsType>;
|
|
372
161
|
}): Promise<({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameService.d.ts","sourceRoot":"","sources":["../../src/services/GameService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"GameService.d.ts","sourceRoot":"","sources":["../../src/services/GameService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAE1B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EAGrB,MAAM,aAAa,CAAA;AAGpB,KAAK,OAAO,GAAG,aAAa,CAAC,YAAY,CAAC,CAAA;AAE1C,UAAU,cAAc,CAAC,CAAC;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,CAAC,CAAA;CACT;AAED,wBAAsB,UAAU,CAAC,MAAM,EACrC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,cAAc,CAAC,MAAM,CAAC,EACpD,GAAG,EAAE,OAAO,EACZ,EACE,MAAM,EACN,YAAY,GACb,EAAE;IAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,G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,EAAE;;CAAA;;;EAiGb;AAED,wBAAsB,uBAAuB,CAC3C,EACE,iBAAiB,EACjB,OAAO,EACP,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,cAAc,EACd,eAAe,EACf,IAAI,GACL;;;;;;;;;;CAAA,EACD,GAAG,EAAE,OAAO,EACZ,EAAE,QAAQ,EAAE;;CAAA;;;;GAgGb;AAED,wBAAgB,0BAA0B,CAAC,IAAI,KAAA,EAAE,GAAG,KAAA,EAAE,EAAE,QAAQ,EAAE;;CAAA;;;EAqIjE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,KAAA,EAAE,GAAG,KAAA,EAAE,EAAE,QAAQ,EAAE;;CAAA;;;EAsD/D"}
|
|
@@ -2,7 +2,8 @@ import * as DB from '@prisma/client';
|
|
|
2
2
|
import { nanoid } from 'nanoid';
|
|
3
3
|
import { repeat, none } from 'ramda';
|
|
4
4
|
import logger from '../lib/logger.js';
|
|
5
|
-
import {
|
|
5
|
+
import { BaseGlobalNotificationType } from '../types.js';
|
|
6
|
+
import { publishGlobalNotification, receiveEvents } from './EventService.js';
|
|
6
7
|
|
|
7
8
|
async function createGame({ name, playerCount, facts }, ctx, { schema, roleAssigner, }) {
|
|
8
9
|
const validatedFacts = schema.validateSync(facts);
|
|
@@ -240,7 +241,7 @@ async function addPeriodSegment({ gameId, periodIx, facts, learningElements, sto
|
|
|
240
241
|
return res;
|
|
241
242
|
}
|
|
242
243
|
async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
243
|
-
logger.info('activating next period');
|
|
244
|
+
logger.info('activating next period for gameId:', gameId);
|
|
244
245
|
// get the current game and as well as the results of the initially active period
|
|
245
246
|
// these will be used by the model to compute the starting situation of the next period
|
|
246
247
|
const game = await ctx.prisma.game.findUnique({
|
|
@@ -300,6 +301,7 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
300
301
|
// NotificationService.publishGlobalNotification({
|
|
301
302
|
// type: GlobalNotificationType.PERIOD_ACTIVATED,
|
|
302
303
|
// })
|
|
304
|
+
let finalTransactionResult;
|
|
303
305
|
switch (game.status) {
|
|
304
306
|
// SCHEDULED -> PREPARATION
|
|
305
307
|
// if the game is scheduled, initialize period results and move to PREPARATION
|
|
@@ -329,7 +331,7 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
329
331
|
// if (Object.keys(gameFactsToUpdate).length > 0) {
|
|
330
332
|
// gameData.facts = gameFactsToUpdate
|
|
331
333
|
// }
|
|
332
|
-
|
|
334
|
+
finalTransactionResult = await ctx.prisma.$transaction([
|
|
333
335
|
ctx.prisma.game.update({
|
|
334
336
|
where: {
|
|
335
337
|
id: gameId,
|
|
@@ -358,7 +360,7 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
358
360
|
}),
|
|
359
361
|
...extras,
|
|
360
362
|
]);
|
|
361
|
-
|
|
363
|
+
break;
|
|
362
364
|
}
|
|
363
365
|
// RUNNING -> CONSOLIDATION
|
|
364
366
|
// if the final segment is running, go on with consolidation of the period
|
|
@@ -376,7 +378,7 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
376
378
|
previousSegmentFacts: game.activePeriod.activeSegment.facts,
|
|
377
379
|
periodIx: currentPeriodIx,
|
|
378
380
|
});
|
|
379
|
-
|
|
381
|
+
finalTransactionResult = await ctx.prisma.$transaction([
|
|
380
382
|
ctx.prisma.game.update({
|
|
381
383
|
data: { status: DB.GameStatus.CONSOLIDATION },
|
|
382
384
|
include: {
|
|
@@ -425,7 +427,7 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
425
427
|
}),
|
|
426
428
|
...extras,
|
|
427
429
|
]);
|
|
428
|
-
|
|
430
|
+
break;
|
|
429
431
|
}
|
|
430
432
|
// CONSOLIDATION -> RESULTS
|
|
431
433
|
// compute period end results and move to the results phase
|
|
@@ -481,7 +483,7 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
481
483
|
};
|
|
482
484
|
// TODO(JJ): Check with RS
|
|
483
485
|
// - when updating the game with the nextPeriodIx it crashes
|
|
484
|
-
|
|
486
|
+
finalTransactionResult = await ctx.prisma.$transaction([
|
|
485
487
|
// update the status and active period of the current game
|
|
486
488
|
ctx.prisma.game.update({
|
|
487
489
|
where: {
|
|
@@ -515,7 +517,7 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
515
517
|
}),
|
|
516
518
|
...extras,
|
|
517
519
|
]);
|
|
518
|
-
|
|
520
|
+
break;
|
|
519
521
|
}
|
|
520
522
|
// RESULTS -> PREPARATION
|
|
521
523
|
// if the game is in the results phase (between periods)
|
|
@@ -554,7 +556,7 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
554
556
|
game,
|
|
555
557
|
periodFacts: game.activePeriod.facts,
|
|
556
558
|
}, ctx, { services });
|
|
557
|
-
|
|
559
|
+
finalTransactionResult = await ctx.prisma.$transaction([
|
|
558
560
|
// update the status and active period of the current game
|
|
559
561
|
ctx.prisma.game.update({
|
|
560
562
|
where: {
|
|
@@ -585,12 +587,37 @@ async function activateNextPeriod({ gameId }, ctx, { services }) {
|
|
|
585
587
|
}),
|
|
586
588
|
...extras,
|
|
587
589
|
]);
|
|
588
|
-
|
|
590
|
+
break;
|
|
589
591
|
}
|
|
590
592
|
default:
|
|
591
593
|
// PREPARATION, PAUSED, COMPLETED, etc.
|
|
594
|
+
logger.warn(`activateNextPeriod called with unhandled game status: ${game.status} for gameId: ${gameId}`);
|
|
592
595
|
return null;
|
|
593
596
|
}
|
|
597
|
+
if (finalTransactionResult) {
|
|
598
|
+
// Re-fetch game state to ensure event reflects committed data
|
|
599
|
+
const gameAfterUpdate = await ctx.prisma.game.findUnique({
|
|
600
|
+
where: { id: gameId },
|
|
601
|
+
// Include what's necessary for the event payload
|
|
602
|
+
select: {
|
|
603
|
+
status: true,
|
|
604
|
+
activePeriodIx: true,
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
if (gameAfterUpdate) {
|
|
608
|
+
const eventToPublish = {
|
|
609
|
+
type: BaseGlobalNotificationType.PERIOD_ACTIVATED,
|
|
610
|
+
facts: {
|
|
611
|
+
gameId: gameId,
|
|
612
|
+
status: gameAfterUpdate.status,
|
|
613
|
+
activePeriodIx: gameAfterUpdate.activePeriodIx,
|
|
614
|
+
},
|
|
615
|
+
};
|
|
616
|
+
publishGlobalNotification(eventToPublish);
|
|
617
|
+
logger.info(`Published ${eventToPublish.type} for game ${gameId}`, eventToPublish.facts);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return finalTransactionResult;
|
|
594
621
|
}
|
|
595
622
|
async function activateNextSegment({ gameId }, ctx, { services }) {
|
|
596
623
|
const game = await ctx.prisma.game.findUnique({
|
|
@@ -632,6 +659,7 @@ async function activateNextSegment({ gameId }, ctx, { services }) {
|
|
|
632
659
|
// NotificationService.publishGlobalNotification({
|
|
633
660
|
// type: GlobalNotificationType.SEGMENT_ACTIVATED,
|
|
634
661
|
// })
|
|
662
|
+
let finalTransactionResult;
|
|
635
663
|
switch (game.status) {
|
|
636
664
|
// PREPARATION -> RUNNING
|
|
637
665
|
// PAUSED -> RUNNING
|
|
@@ -649,7 +677,7 @@ async function activateNextSegment({ gameId }, ctx, { services }) {
|
|
|
649
677
|
const { results, extras } = computeSegmentStartResults(game, ctx, {
|
|
650
678
|
services,
|
|
651
679
|
});
|
|
652
|
-
|
|
680
|
+
finalTransactionResult = await ctx.prisma.$transaction([
|
|
653
681
|
ctx.prisma.game.update({
|
|
654
682
|
where: {
|
|
655
683
|
id: gameId,
|
|
@@ -664,6 +692,8 @@ async function activateNextSegment({ gameId }, ctx, { services }) {
|
|
|
664
692
|
},
|
|
665
693
|
data: {
|
|
666
694
|
status: DB.GameStatus.RUNNING,
|
|
695
|
+
// TODO(JJ): We need this to be updated
|
|
696
|
+
// activeSegmentIx: nextSegmentIx,
|
|
667
697
|
...(updatedGameFacts ? { facts: game.facts } : {}),
|
|
668
698
|
},
|
|
669
699
|
}),
|
|
@@ -705,7 +735,7 @@ async function activateNextSegment({ gameId }, ctx, { services }) {
|
|
|
705
735
|
}),
|
|
706
736
|
...extras,
|
|
707
737
|
]);
|
|
708
|
-
|
|
738
|
+
break;
|
|
709
739
|
}
|
|
710
740
|
// RUNNING -> PAUSED
|
|
711
741
|
// compute the segment results of the current segment and set to paused
|
|
@@ -717,7 +747,7 @@ async function activateNextSegment({ gameId }, ctx, { services }) {
|
|
|
717
747
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
718
748
|
services,
|
|
719
749
|
});
|
|
720
|
-
|
|
750
|
+
finalTransactionResult = await ctx.prisma.$transaction([
|
|
721
751
|
ctx.prisma.game.update({
|
|
722
752
|
where: { id: gameId },
|
|
723
753
|
include: {
|
|
@@ -760,11 +790,40 @@ async function activateNextSegment({ gameId }, ctx, { services }) {
|
|
|
760
790
|
}),
|
|
761
791
|
...extras,
|
|
762
792
|
]);
|
|
763
|
-
|
|
793
|
+
break;
|
|
764
794
|
}
|
|
765
795
|
default:
|
|
796
|
+
logger.warn(`activateNextSegment called with unhandled game status: ${game.status} for gameId: ${gameId}`);
|
|
766
797
|
return null;
|
|
767
798
|
}
|
|
799
|
+
if (finalTransactionResult) {
|
|
800
|
+
const gameAfterUpdate = await ctx.prisma.game.findUnique({
|
|
801
|
+
where: { id: gameId },
|
|
802
|
+
select: {
|
|
803
|
+
status: true,
|
|
804
|
+
activePeriodIx: true,
|
|
805
|
+
activePeriod: {
|
|
806
|
+
include: {
|
|
807
|
+
activeSegment: true,
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
},
|
|
811
|
+
});
|
|
812
|
+
if (gameAfterUpdate && gameAfterUpdate.activePeriod) {
|
|
813
|
+
const eventToPublish = {
|
|
814
|
+
type: BaseGlobalNotificationType.SEGMENT_ACTIVATED,
|
|
815
|
+
facts: {
|
|
816
|
+
gameId: gameId,
|
|
817
|
+
status: gameAfterUpdate.status,
|
|
818
|
+
activePeriodIx: gameAfterUpdate.activePeriodIx,
|
|
819
|
+
activeSegmentIx: gameAfterUpdate.activePeriod.activeSegmentIx,
|
|
820
|
+
},
|
|
821
|
+
};
|
|
822
|
+
publishGlobalNotification(eventToPublish);
|
|
823
|
+
logger.info(`Published ${eventToPublish.type} for game ${gameId}`, eventToPublish.facts);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return finalTransactionResult;
|
|
768
827
|
}
|
|
769
828
|
async function updatePlayerData({ name, facts }, ctx, { schema }) {
|
|
770
829
|
// if none of the arguments have been provided, no update is performed
|