av6-core 1.1.6 → 1.1.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.js CHANGED
@@ -2027,7 +2027,7 @@ var AuditLogger = class {
2027
2027
  if (!config || !config.isAuditable) {
2028
2028
  return;
2029
2029
  }
2030
- const message = config.message;
2030
+ const message = payload.type === "ERROR" ? payload.message : config.message;
2031
2031
  const type = payload.type ?? "INFO";
2032
2032
  const ccId = payload.ccId ?? ctxCcId ?? 0;
2033
2033
  await prisma.commonAudit.create({
@@ -2064,10 +2064,7 @@ var AuditProxy = class {
2064
2064
  return original;
2065
2065
  }
2066
2066
  const isOwn = Object.prototype.hasOwnProperty.call(target, prop);
2067
- if (!isOwn) {
2068
- return original;
2069
- }
2070
- if (prop === "constructor") {
2067
+ if (!isOwn || prop === "constructor") {
2071
2068
  return original;
2072
2069
  }
2073
2070
  if (wrappedCache.has(prop)) {
@@ -2085,14 +2082,16 @@ var AuditProxy = class {
2085
2082
  throw err;
2086
2083
  } finally {
2087
2084
  const hasError = !!error;
2088
- const message = hasError ? `Error in ${serviceName}.${methodName}` : `Executed ${serviceName}.${methodName}`;
2089
- await logger.logIfEnabled({
2085
+ const message = hasError ? error.message : `Executed ${serviceName}.${methodName}`;
2086
+ logger.logIfEnabled({
2090
2087
  service: serviceName,
2091
2088
  method: methodName,
2092
2089
  payload: {
2093
2090
  message,
2094
2091
  type: hasError ? "ERROR" : "INFO"
2095
2092
  }
2093
+ }).catch((err) => {
2094
+ console.error("[Audit] Failed to log audit:", err);
2096
2095
  });
2097
2096
  }
2098
2097
  };
package/dist/index.mjs CHANGED
@@ -1978,7 +1978,7 @@ var AuditLogger = class {
1978
1978
  if (!config || !config.isAuditable) {
1979
1979
  return;
1980
1980
  }
1981
- const message = config.message;
1981
+ const message = payload.type === "ERROR" ? payload.message : config.message;
1982
1982
  const type = payload.type ?? "INFO";
1983
1983
  const ccId = payload.ccId ?? ctxCcId ?? 0;
1984
1984
  await prisma.commonAudit.create({
@@ -2015,10 +2015,7 @@ var AuditProxy = class {
2015
2015
  return original;
2016
2016
  }
2017
2017
  const isOwn = Object.prototype.hasOwnProperty.call(target, prop);
2018
- if (!isOwn) {
2019
- return original;
2020
- }
2021
- if (prop === "constructor") {
2018
+ if (!isOwn || prop === "constructor") {
2022
2019
  return original;
2023
2020
  }
2024
2021
  if (wrappedCache.has(prop)) {
@@ -2036,14 +2033,16 @@ var AuditProxy = class {
2036
2033
  throw err;
2037
2034
  } finally {
2038
2035
  const hasError = !!error;
2039
- const message = hasError ? `Error in ${serviceName}.${methodName}` : `Executed ${serviceName}.${methodName}`;
2040
- await logger.logIfEnabled({
2036
+ const message = hasError ? error.message : `Executed ${serviceName}.${methodName}`;
2037
+ logger.logIfEnabled({
2041
2038
  service: serviceName,
2042
2039
  method: methodName,
2043
2040
  payload: {
2044
2041
  message,
2045
2042
  type: hasError ? "ERROR" : "INFO"
2046
2043
  }
2044
+ }).catch((err) => {
2045
+ console.error("[Audit] Failed to log audit:", err);
2047
2046
  });
2048
2047
  }
2049
2048
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "av6-core",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",