@gbl-uzh/platform 0.4.6 → 0.4.8

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
@@ -142,13 +142,16 @@ declare function loginAsTeam({ token }: LoginAsTeamArgs, ctx: CtxWithPrisma<Pris
142
142
  createdAt: Date;
143
143
  updatedAt: Date;
144
144
  }, unknown> & {}) | null>;
145
+ declare function logoutAsTeam(ctx: CtxWithPrisma<PrismaClient>): Promise<boolean>;
145
146
 
146
147
  declare const AccountService_createLoginToken: typeof createLoginToken;
147
148
  declare const AccountService_loginAsTeam: typeof loginAsTeam;
149
+ declare const AccountService_logoutAsTeam: typeof logoutAsTeam;
148
150
  declare namespace AccountService {
149
151
  export {
150
152
  AccountService_createLoginToken as createLoginToken,
151
153
  AccountService_loginAsTeam as loginAsTeam,
154
+ AccountService_logoutAsTeam as logoutAsTeam,
152
155
  };
153
156
  }
154
157
 
package/dist/index.js CHANGED
@@ -59,7 +59,8 @@ var logger_default = logger;
59
59
  var AccountService_exports = {};
60
60
  __export(AccountService_exports, {
61
61
  createLoginToken: () => createLoginToken,
62
- loginAsTeam: () => loginAsTeam
62
+ loginAsTeam: () => loginAsTeam,
63
+ logoutAsTeam: () => logoutAsTeam
63
64
  });
64
65
  var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
65
66
  var import_node_assert = require("assert");
@@ -136,6 +137,21 @@ async function loginAsTeam({ token }, ctx) {
136
137
  }
137
138
  return matchingPlayer;
138
139
  }
140
+ async function logoutAsTeam(ctx) {
141
+ if (!ctx.user?.sub)
142
+ return false;
143
+ const matchingPlayer = await ctx.prisma.player.findUnique({
144
+ where: {
145
+ id: ctx.user.sub
146
+ }
147
+ });
148
+ if (matchingPlayer) {
149
+ const cookieName = process.env.NODE_ENV === "production" ? "__Secure-next-auth.session-token" : "next-auth.session-token";
150
+ (0, import_nookies.destroyCookie)(ctx, cookieName);
151
+ return true;
152
+ }
153
+ return false;
154
+ }
139
155
 
140
156
  // src/services/EventService.ts
141
157
  var EventService_exports = {};
package/dist/nexus.js CHANGED
@@ -122,7 +122,9 @@ var StoryElement = (0, import_nexus2.objectType)({
122
122
  });
123
123
  t.nonNull.string("title");
124
124
  t.string("content");
125
- t.string("contentRole");
125
+ t.field("contentRole", {
126
+ type: "JSONObject"
127
+ });
126
128
  t.field("reward", {
127
129
  type: "JSONObject"
128
130
  });
@@ -438,6 +440,21 @@ async function loginAsTeam({ token }, ctx) {
438
440
  }
439
441
  return matchingPlayer;
440
442
  }
443
+ async function logoutAsTeam(ctx) {
444
+ if (!ctx.user?.sub)
445
+ return false;
446
+ const matchingPlayer = await ctx.prisma.player.findUnique({
447
+ where: {
448
+ id: ctx.user.sub
449
+ }
450
+ });
451
+ if (matchingPlayer) {
452
+ const cookieName = process.env.NODE_ENV === "production" ? "__Secure-next-auth.session-token" : "next-auth.session-token";
453
+ (0, import_nookies.destroyCookie)(ctx, cookieName);
454
+ return true;
455
+ }
456
+ return false;
457
+ }
441
458
 
442
459
  // src/services/GameService.ts
443
460
  var DB6 = __toESM(require("@prisma/client"));
@@ -2246,6 +2263,11 @@ function generateBaseMutations({
2246
2263
  return loginAsTeam(args, ctx);
2247
2264
  }
2248
2265
  });
2266
+ t.boolean("logoutAsTeam", {
2267
+ async resolve(_, __, ctx) {
2268
+ return logoutAsTeam(ctx);
2269
+ }
2270
+ });
2249
2271
  t.field("createGame", {
2250
2272
  type: Game,
2251
2273
  args: {
@@ -0,0 +1,3 @@
1
+ mutation LogoutAsTeam {
2
+ logoutAsTeam
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gbl-uzh/platform",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "license": "LGPL-3.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",