@unchainedshop/api 4.8.1 → 4.8.3

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.
@@ -43,8 +43,9 @@ export default async function bulkImportMiddleware(req, res) {
43
43
  res.status(200).send(work);
44
44
  }
45
45
  catch (e) {
46
- logger.error(e);
47
- res.status(503).send({ name: e.name, code: e.code, message: e.message });
46
+ logger.error(e.message);
47
+ const cause = e.cause?.issues || e.cause;
48
+ res.status(503).send({ name: e.name, code: e.code, message: e.message, cause });
48
49
  return;
49
50
  }
50
51
  }
@@ -37,9 +37,10 @@ const bulkImportHandler = async (req, res) => {
37
37
  return res.send(work);
38
38
  }
39
39
  catch (e) {
40
- logger.error(e);
40
+ logger.error(e.message);
41
41
  res.status(503);
42
- return res.send({ name: e.name, code: e.code, message: e.message });
42
+ const cause = e.cause?.issues || e.cause;
43
+ return res.send({ name: e.name, code: e.code, message: e.message, cause });
43
44
  }
44
45
  };
45
46
  export default bulkImportHandler;
@@ -29,6 +29,7 @@ const middlewareHook = async function middlewareHook(req, reply) {
29
29
  const { impersonator } = options;
30
30
  req.session.userId = user._id;
31
31
  req.session.impersonatorId = impersonator?._id;
32
+ await req.session.save();
32
33
  const tokenObject = {
33
34
  _id: req.session.sessionId,
34
35
  userId: user._id,
@@ -45,6 +46,7 @@ const middlewareHook = async function middlewareHook(req, reply) {
45
46
  };
46
47
  req.session.userId = null;
47
48
  req.session.impersonatorId = null;
49
+ await req.session.save();
48
50
  await emit(API_EVENTS.API_LOGOUT, tokenObject);
49
51
  return true;
50
52
  };
@@ -109,6 +111,8 @@ export const connect = (fastify, { graphqlHandler, db, unchainedAPI, }, { allowR
109
111
  fastify.register(fastifySession, {
110
112
  secret: process.env.UNCHAINED_TOKEN_SECRET,
111
113
  cookieName,
114
+ rolling: false,
115
+ saveUninitialized: false,
112
116
  store: MongoStore.create({
113
117
  client: db.client,
114
118
  dbName: db.databaseName,
@@ -1,6 +1,6 @@
1
1
  import { log } from '@unchainedshop/logger';
2
2
  export default async function addWork(root, workData, { modules, userId }) {
3
- const { type, input } = workData;
4
- log(`mutation addWork ${type} ${JSON.stringify(input)}`, { userId });
3
+ const { type, priority, retries, worker } = workData;
4
+ log(`mutation addWork ${type}`, { userId, priority, retries, worker });
5
5
  return modules.worker.addWork(workData);
6
6
  }
@@ -0,0 +1 @@
1
+ export default function registeredEventTypes(): string[];
@@ -0,0 +1,4 @@
1
+ import { getRegisteredEvents } from '@unchainedshop/events';
2
+ export default function registeredEventTypes() {
3
+ return getRegisteredEvents();
4
+ }
@@ -68,6 +68,7 @@ declare const _default: {
68
68
  event: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
69
69
  events: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
70
70
  eventsCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
71
+ registeredEventTypes: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
71
72
  validateResetPasswordToken: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
72
73
  validateVerifyEmailToken: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
73
74
  workStatistics: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
@@ -70,6 +70,7 @@ import workQueueCount from "./worker/workQueueCount.js";
70
70
  import validateResetPasswordToken from "./users/validateResetPasswordToken.js";
71
71
  import validateVerifyEmailToken from "./users/validateVerifyEmailToken.js";
72
72
  import eventStatistics from "./events/eventStatistics.js";
73
+ import registeredEventTypes from "./events/registeredEventTypes.js";
73
74
  import orderStatistics from "./orders/orderStatistics.js";
74
75
  import impersonator from "./users/impersonator.js";
75
76
  export default {
@@ -140,6 +141,7 @@ export default {
140
141
  event: acl(actions.viewEvent)(event),
141
142
  events: acl(actions.viewEvents)(events),
142
143
  eventsCount: acl(actions.viewEvents)(eventsCount),
144
+ registeredEventTypes: acl(actions.viewEvents)(registeredEventTypes),
143
145
  validateResetPasswordToken: acl(actions.resetPassword)(validateResetPasswordToken),
144
146
  validateVerifyEmailToken: acl(actions.verifyEmail)(validateVerifyEmailToken),
145
147
  workStatistics: acl(actions.viewStatistics)(workStatistics),
@@ -491,6 +491,11 @@ export default [
491
491
  """
492
492
  eventsCount(types: [String!], queryString: String, created: DateFilterInput): Int!
493
493
 
494
+ """
495
+ Get all registered event types
496
+ """
497
+ registeredEventTypes: [String!]!
498
+
494
499
  """
495
500
  Determines if a token is valid/active for reset password
496
501
  """
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/api",
3
3
  "description": "GraphQL API layer for the Unchained Engine with Express/Fastify adapters and MCP server",
4
- "version": "4.8.1",
4
+ "version": "4.8.3",
5
5
  "main": "lib/api-index.js",
6
6
  "types": "lib/api-index.d.ts",
7
7
  "type": "module",