@arkyn/server 2.2.2 → 2.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"getCaller.d.ts","sourceRoot":"","sources":["../../src/services/getCaller.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,iBAAS,SAAS;;;EAyCjB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"getCaller.d.ts","sourceRoot":"","sources":["../../src/services/getCaller.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,iBAAS,SAAS;;;EA+BjB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -12,34 +12,28 @@ import path from "path";
12
12
  */
13
13
  function getCaller() {
14
14
  const projectRoot = process.cwd();
15
- const error = new Error();
16
- const stackLines = error.stack?.split("\n").map((line) => line.trim()) || [];
17
- let callerInfo = "Unknown caller";
18
- let functionName = "Unknown function";
19
- const relevantLines = stackLines.filter((line) => !line.includes("@arkyn/server"));
20
- let foundGetCaller = false;
21
- for (const line of relevantLines) {
22
- if (!foundGetCaller) {
23
- if (line.includes("getCaller")) {
24
- foundGetCaller = true;
25
- }
26
- continue;
27
- }
28
- const match = line.match(/at (.+?) \((.+?)\)/) || line.match(/at (.+)/);
29
- if (match) {
30
- const rawFuncName = match[1]?.split(" ")[0] || "";
31
- functionName =
32
- rawFuncName && !rawFuncName.includes("/")
33
- ? rawFuncName
34
- : "Unknown function";
35
- let fullPath = match[2] || match[1];
36
- if (fullPath.startsWith(projectRoot)) {
37
- fullPath = path.relative(projectRoot, fullPath);
38
- }
39
- callerInfo = fullPath;
40
- break;
15
+ const err = new Error();
16
+ const stack = err.stack || "";
17
+ const stackLines = stack.split("\n").map((line) => line.trim());
18
+ const callerLine = stackLines[4] || "";
19
+ let functionName = "unknown";
20
+ let callerInfo = "unknown location";
21
+ const functionMatch = callerLine.match(/at\s+([^\s]+)\s+\((.*)\)/);
22
+ if (functionMatch) {
23
+ functionName = functionMatch[1];
24
+ callerInfo = functionMatch[2];
25
+ }
26
+ else {
27
+ const locationMatch = callerLine.match(/at\s+(.*)/);
28
+ if (locationMatch) {
29
+ callerInfo = locationMatch[1];
30
+ const pathParts = callerInfo.split("/");
31
+ const lastPart = pathParts[pathParts.length - 1] || "";
32
+ const fileParts = lastPart.split(":");
33
+ functionName = fileParts[0] || "unknown";
41
34
  }
42
35
  }
36
+ callerInfo = path.relative(projectRoot, callerInfo);
43
37
  return { functionName, callerInfo };
44
38
  }
45
39
  export { getCaller };
@@ -1 +1 @@
1
- {"version":3,"file":"httpDebug.d.ts","sourceRoot":"","sources":["../../src/services/httpDebug.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,QAyBtD;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"httpDebug.d.ts","sourceRoot":"","sources":["../../src/services/httpDebug.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,QA0BtD;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -47,10 +47,10 @@ function httpDebug(name, body, cause) {
47
47
  if (cause) {
48
48
  consoleData += `${debugName} Cause: ${JSON.stringify(cause, null, 2)}\n`;
49
49
  }
50
- console.log(consoleData);
51
50
  const arkynKeys = InboxFlowInstance.getInboxConfig();
52
51
  if (arkynKeys)
53
52
  console.log(arkynKeys);
53
+ console.log(consoleData);
54
54
  }
55
55
  }
56
56
  export { httpDebug };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
@@ -15,43 +15,33 @@ import path from "path";
15
15
  function getCaller() {
16
16
  const projectRoot = process.cwd();
17
17
 
18
- const error = new Error();
19
- const stackLines = error.stack?.split("\n").map((line) => line.trim()) || [];
20
-
21
- let callerInfo = "Unknown caller";
22
- let functionName = "Unknown function";
23
-
24
- const relevantLines = stackLines.filter(
25
- (line) => !line.includes("@arkyn/server")
26
- );
27
-
28
- let foundGetCaller = false;
29
- for (const line of relevantLines) {
30
- if (!foundGetCaller) {
31
- if (line.includes("getCaller")) {
32
- foundGetCaller = true;
33
- }
34
- continue;
35
- }
36
-
37
- const match = line.match(/at (.+?) \((.+?)\)/) || line.match(/at (.+)/);
38
- if (match) {
39
- const rawFuncName = match[1]?.split(" ")[0] || "";
40
-
41
- functionName =
42
- rawFuncName && !rawFuncName.includes("/")
43
- ? rawFuncName
44
- : "Unknown function";
45
-
46
- let fullPath = match[2] || match[1];
47
- if (fullPath.startsWith(projectRoot)) {
48
- fullPath = path.relative(projectRoot, fullPath);
49
- }
50
- callerInfo = fullPath;
51
- break;
18
+ const err = new Error();
19
+ const stack = err.stack || "";
20
+
21
+ const stackLines = stack.split("\n").map((line) => line.trim());
22
+
23
+ const callerLine = stackLines[4] || "";
24
+
25
+ let functionName = "unknown";
26
+ let callerInfo = "unknown location";
27
+
28
+ const functionMatch = callerLine.match(/at\s+([^\s]+)\s+\((.*)\)/);
29
+ if (functionMatch) {
30
+ functionName = functionMatch[1];
31
+ callerInfo = functionMatch[2];
32
+ } else {
33
+ const locationMatch = callerLine.match(/at\s+(.*)/);
34
+ if (locationMatch) {
35
+ callerInfo = locationMatch[1];
36
+ const pathParts = callerInfo.split("/");
37
+ const lastPart = pathParts[pathParts.length - 1] || "";
38
+ const fileParts = lastPart.split(":");
39
+ functionName = fileParts[0] || "unknown";
52
40
  }
53
41
  }
54
42
 
43
+ callerInfo = path.relative(projectRoot, callerInfo);
44
+
55
45
  return { functionName, callerInfo };
56
46
  }
57
47
 
@@ -55,9 +55,10 @@ function httpDebug(name: string, body: any, cause?: any) {
55
55
  consoleData += `${debugName} Cause: ${JSON.stringify(cause, null, 2)}\n`;
56
56
  }
57
57
 
58
- console.log(consoleData);
59
58
  const arkynKeys = InboxFlowInstance.getInboxConfig();
60
59
  if (arkynKeys) console.log(arkynKeys);
60
+
61
+ console.log(consoleData);
61
62
  }
62
63
  }
63
64