@gbl-uzh/platform 0.4.0 → 0.4.2
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 +1116 -123
- package/dist/index.js +14 -14
- package/dist/lib/apollo.js +12 -16
- package/dist/nexus.js +21 -16
- package/dist/ops/QPastResults.graphql +6 -0
- package/dist/schema.prisma +1 -1
- package/package.json +8 -6
package/dist/index.js
CHANGED
|
@@ -123,17 +123,13 @@ async function loginAsTeam({ token }, ctx) {
|
|
|
123
123
|
role: "PLAYER" /* PLAYER */,
|
|
124
124
|
token: matchingPlayer.token
|
|
125
125
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
httpOnly: process.env.NODE_ENV === "production",
|
|
134
|
-
secure: process.env.NODE_ENV === "production"
|
|
135
|
-
}
|
|
136
|
-
);
|
|
126
|
+
const cookieName = process.env.NODE_ENV === "production" ? "__Secure-next-auth.session-token" : "next-auth.session-token";
|
|
127
|
+
(0, import_nookies.setCookie)(ctx, cookieName, jwt, {
|
|
128
|
+
path: "/",
|
|
129
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
130
|
+
httpOnly: process.env.NODE_ENV === "production",
|
|
131
|
+
secure: process.env.NODE_ENV === "production"
|
|
132
|
+
});
|
|
137
133
|
} catch (err) {
|
|
138
134
|
console.error(err);
|
|
139
135
|
return null;
|
|
@@ -433,7 +429,6 @@ async function createGame({ name, playerCount }, ctx, { roleAssigner }) {
|
|
|
433
429
|
}
|
|
434
430
|
async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
435
431
|
const validatedFacts = schema.validateSync(facts);
|
|
436
|
-
console.log(gameId);
|
|
437
432
|
const game = await ctx.prisma.game.findUnique({
|
|
438
433
|
where: {
|
|
439
434
|
id: gameId
|
|
@@ -457,7 +452,6 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
457
452
|
});
|
|
458
453
|
if (!game)
|
|
459
454
|
return null;
|
|
460
|
-
console.log(game);
|
|
461
455
|
const index = game.periods[0]?.index + 1 || 0;
|
|
462
456
|
const { result: initializedFacts } = reducers.Period.apply(validatedFacts, {
|
|
463
457
|
type: reducers.Period.ActionTypes.PERIOD_INITIALIZE,
|
|
@@ -468,6 +462,11 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
468
462
|
periodIx: index
|
|
469
463
|
}
|
|
470
464
|
});
|
|
465
|
+
console.log(
|
|
466
|
+
game.periods[0]?.facts,
|
|
467
|
+
game.periods[0]?.segments[0]?.facts,
|
|
468
|
+
initializedFacts
|
|
469
|
+
);
|
|
471
470
|
return ctx.prisma.period.upsert({
|
|
472
471
|
where: {
|
|
473
472
|
gameId_index: {
|
|
@@ -1722,7 +1721,8 @@ async function getPlayerResult(args, ctx) {
|
|
|
1722
1721
|
}
|
|
1723
1722
|
},
|
|
1724
1723
|
include: {
|
|
1725
|
-
period: true
|
|
1724
|
+
period: true,
|
|
1725
|
+
segment: true
|
|
1726
1726
|
}
|
|
1727
1727
|
});
|
|
1728
1728
|
const playerResult = await ctx.prisma.playerResult.findUnique({
|
package/dist/lib/apollo.js
CHANGED
|
@@ -43,28 +43,23 @@ var import_react = require("react");
|
|
|
43
43
|
// src/lib/SSELink.ts
|
|
44
44
|
var import_core = require("@apollo/client/core");
|
|
45
45
|
var import_graphql = require("graphql");
|
|
46
|
+
var import_graphql_sse = require("graphql-sse");
|
|
46
47
|
var SSELink = class extends import_core.ApolloLink {
|
|
48
|
+
client;
|
|
47
49
|
constructor(options) {
|
|
48
50
|
super();
|
|
49
|
-
this.
|
|
51
|
+
this.client = (0, import_graphql_sse.createClient)(options);
|
|
50
52
|
}
|
|
51
53
|
request(operation) {
|
|
52
|
-
const url = new URL(this.options.url);
|
|
53
|
-
url.searchParams.append("query", (0, import_graphql.print)(operation.query));
|
|
54
|
-
url.searchParams.append("variables", JSON.stringify(operation.variables));
|
|
55
54
|
return new import_core.Observable((sink) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
sink.
|
|
55
|
+
return this.client.subscribe(
|
|
56
|
+
{ ...operation, query: (0, import_graphql.print)(operation.query) },
|
|
57
|
+
{
|
|
58
|
+
next: sink.next.bind(sink),
|
|
59
|
+
complete: sink.complete.bind(sink),
|
|
60
|
+
error: sink.error.bind(sink)
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
eventsource.onerror = function(error) {
|
|
65
|
-
sink.error(error);
|
|
66
|
-
};
|
|
67
|
-
return () => eventsource.close();
|
|
62
|
+
);
|
|
68
63
|
});
|
|
69
64
|
}
|
|
70
65
|
};
|
|
@@ -81,7 +76,8 @@ function createIsomorphLink() {
|
|
|
81
76
|
});
|
|
82
77
|
if (isBrowser) {
|
|
83
78
|
const sseLink = new SSELink_default({
|
|
84
|
-
url: process.env.NEXT_PUBLIC_API_URL
|
|
79
|
+
url: process.env.NEXT_PUBLIC_API_URL,
|
|
80
|
+
credentials: "same-origin"
|
|
85
81
|
});
|
|
86
82
|
httpLink = (0, import_client.split)(
|
|
87
83
|
({ query }) => {
|
package/dist/nexus.js
CHANGED
|
@@ -425,17 +425,13 @@ async function loginAsTeam({ token }, ctx) {
|
|
|
425
425
|
role: "PLAYER" /* PLAYER */,
|
|
426
426
|
token: matchingPlayer.token
|
|
427
427
|
});
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
httpOnly: process.env.NODE_ENV === "production",
|
|
436
|
-
secure: process.env.NODE_ENV === "production"
|
|
437
|
-
}
|
|
438
|
-
);
|
|
428
|
+
const cookieName = process.env.NODE_ENV === "production" ? "__Secure-next-auth.session-token" : "next-auth.session-token";
|
|
429
|
+
(0, import_nookies.setCookie)(ctx, cookieName, jwt, {
|
|
430
|
+
path: "/",
|
|
431
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
432
|
+
httpOnly: process.env.NODE_ENV === "production",
|
|
433
|
+
secure: process.env.NODE_ENV === "production"
|
|
434
|
+
});
|
|
439
435
|
} catch (err) {
|
|
440
436
|
console.error(err);
|
|
441
437
|
return null;
|
|
@@ -723,7 +719,6 @@ async function createGame({ name, playerCount }, ctx, { roleAssigner }) {
|
|
|
723
719
|
}
|
|
724
720
|
async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
725
721
|
const validatedFacts = schema.validateSync(facts);
|
|
726
|
-
console.log(gameId);
|
|
727
722
|
const game = await ctx.prisma.game.findUnique({
|
|
728
723
|
where: {
|
|
729
724
|
id: gameId
|
|
@@ -747,7 +742,6 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
747
742
|
});
|
|
748
743
|
if (!game)
|
|
749
744
|
return null;
|
|
750
|
-
console.log(game);
|
|
751
745
|
const index = game.periods[0]?.index + 1 || 0;
|
|
752
746
|
const { result: initializedFacts } = reducers.Period.apply(validatedFacts, {
|
|
753
747
|
type: reducers.Period.ActionTypes.PERIOD_INITIALIZE,
|
|
@@ -758,6 +752,11 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
758
752
|
periodIx: index
|
|
759
753
|
}
|
|
760
754
|
});
|
|
755
|
+
console.log(
|
|
756
|
+
game.periods[0]?.facts,
|
|
757
|
+
game.periods[0]?.segments[0]?.facts,
|
|
758
|
+
initializedFacts
|
|
759
|
+
);
|
|
761
760
|
return ctx.prisma.period.upsert({
|
|
762
761
|
where: {
|
|
763
762
|
gameId_index: {
|
|
@@ -1998,7 +1997,8 @@ async function getPlayerResult(args, ctx) {
|
|
|
1998
1997
|
}
|
|
1999
1998
|
},
|
|
2000
1999
|
include: {
|
|
2001
|
-
period: true
|
|
2000
|
+
period: true,
|
|
2001
|
+
segment: true
|
|
2002
2002
|
}
|
|
2003
2003
|
});
|
|
2004
2004
|
const playerResult = await ctx.prisma.playerResult.findUnique({
|
|
@@ -2452,9 +2452,11 @@ function generateBaseQueries() {
|
|
|
2452
2452
|
);
|
|
2453
2453
|
}
|
|
2454
2454
|
});
|
|
2455
|
-
t.
|
|
2455
|
+
t.field("self", {
|
|
2456
2456
|
type: Player,
|
|
2457
2457
|
async resolve(_, args, ctx) {
|
|
2458
|
+
if (!ctx.user)
|
|
2459
|
+
return null;
|
|
2458
2460
|
return getPlayerData({ playerId: ctx.user.sub }, ctx);
|
|
2459
2461
|
}
|
|
2460
2462
|
});
|
|
@@ -2507,7 +2509,10 @@ function generateBaseSubscriptions() {
|
|
|
2507
2509
|
t.list.nonNull.field("eventsUser", {
|
|
2508
2510
|
type: Event,
|
|
2509
2511
|
async subscribe(_, args, ctx) {
|
|
2510
|
-
|
|
2512
|
+
if (ctx.user) {
|
|
2513
|
+
return pubSub.subscribe("user:events", String(ctx.user.sub));
|
|
2514
|
+
}
|
|
2515
|
+
return pubSub.subscribe("user:events", "anonymous");
|
|
2511
2516
|
},
|
|
2512
2517
|
async resolve(payload) {
|
|
2513
2518
|
return payload;
|
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 = ["fullTextSearch", "fullTextIndex", "postgresqlExtensions", "fieldReference", "
|
|
9
|
+
previewFeatures = ["fullTextSearch", "fullTextIndex", "postgresqlExtensions", "fieldReference", "extendedWhereUnique"]
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
model Account {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gbl-uzh/platform",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"license": "LGPL-3.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,21 +29,23 @@
|
|
|
29
29
|
"npm-run-all": "4.1.5",
|
|
30
30
|
"ts-jest": "29.1.0",
|
|
31
31
|
"ts-node": "10.9.1",
|
|
32
|
-
"tsup": "
|
|
33
|
-
"typescript": "5.
|
|
32
|
+
"tsup": "7.1.0",
|
|
33
|
+
"typescript": "5.1.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@apollo/client": "^3.7.0",
|
|
37
|
-
"@prisma/client": "^4.
|
|
37
|
+
"@prisma/client": "^4.16.1",
|
|
38
38
|
"@uzh-bf/design-system": "^1.0.0",
|
|
39
39
|
"graphql": "^16.6.0",
|
|
40
40
|
"graphql-scalars": "^1.19.0",
|
|
41
|
-
"graphql-
|
|
41
|
+
"graphql-sse": "^2.0.0",
|
|
42
|
+
"graphql-yoga": "^4.0.0",
|
|
42
43
|
"jsonwebtoken": "^9.0.0",
|
|
43
44
|
"next": "^13.0.0",
|
|
45
|
+
"next-auth": "^4.0.0",
|
|
44
46
|
"nexus": "^1.3.0",
|
|
45
47
|
"nookies": "^2.5.2",
|
|
46
|
-
"prisma": "^4.
|
|
48
|
+
"prisma": "^4.16.1",
|
|
47
49
|
"ramda": "^0.29.0",
|
|
48
50
|
"react": "^18.0.0",
|
|
49
51
|
"yup": "^1.0.0"
|