@prismatic-io/spectral 10.3.11 → 10.3.13

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.
@@ -4,6 +4,7 @@ exports.createDebugContext = createDebugContext;
4
4
  exports.logDebugResults = logDebugResults;
5
5
  const node_process_1 = require("node:process");
6
6
  const node_perf_hooks_1 = require("node:perf_hooks");
7
+ const MEMORY_USAGE_CONVERSION = 1024 * 1024;
7
8
  function createDebugContext(context) {
8
9
  const globalDebug = Boolean(context.globalDebug);
9
10
  return {
@@ -26,11 +27,13 @@ function createDebugContext(context) {
26
27
  },
27
28
  memoryUsage: (actionContext, label, showDetail) => {
28
29
  if (globalDebug) {
29
- // @ts-expect-error: memoryUsage.rss() is documented but not typed
30
- const usage = showDetail ? (0, node_process_1.memoryUsage)() : node_process_1.memoryUsage.rss();
30
+ const usage = showDetail
31
+ ? memoryUsageInMB()
32
+ : // @ts-expect-error: memoryUsage.rss() is documented but not typed
33
+ node_process_1.memoryUsage.rss() / MEMORY_USAGE_CONVERSION;
31
34
  actionContext.debug.results.memoryUsage.push({
32
35
  mark: label,
33
- rss: typeof usage === "number" ? usage / 1000000 : usage.rss / 1000000,
36
+ rss: typeof usage === "number" ? usage : usage.rss,
34
37
  detail: typeof usage === "number" ? undefined : usage,
35
38
  });
36
39
  }
@@ -47,3 +50,16 @@ function logDebugResults(context) {
47
50
  context.logger.metric(context.debug.results);
48
51
  }
49
52
  }
53
+ function memoryUsageInMB() {
54
+ const usage = (0, node_process_1.memoryUsage)();
55
+ return Object.keys(usage).reduce((accum, key) => {
56
+ accum[key] = usage[key] / MEMORY_USAGE_CONVERSION;
57
+ return accum;
58
+ }, {
59
+ rss: -1,
60
+ heapTotal: -1,
61
+ heapUsed: -1,
62
+ external: -1,
63
+ arrayBuffers: -1,
64
+ });
65
+ }
@@ -99,6 +99,7 @@ export interface TriggerPayload {
99
99
  integration: IntegrationAttributes;
100
100
  flow: FlowAttributes;
101
101
  startedAt: string;
102
+ globalDebug: boolean;
102
103
  }
103
104
  interface HttpResponse {
104
105
  statusCode: number;
package/dist/testing.js CHANGED
@@ -208,6 +208,7 @@ const defaultTriggerPayload = () => {
208
208
  name: "Flow 1",
209
209
  },
210
210
  startedAt: new Date().toISOString(),
211
+ globalDebug: false,
211
212
  };
212
213
  };
213
214
  exports.defaultTriggerPayload = defaultTriggerPayload;
@@ -49,15 +49,16 @@ interface DebugResult {
49
49
  memoryUsage: Array<{
50
50
  mark: string;
51
51
  rss: number;
52
- detail?: {
53
- rss: number;
54
- heapTotal: number;
55
- heapUsed: number;
56
- external: number;
57
- arrayBuffers: number;
58
- };
52
+ detail?: MemoryUsage;
59
53
  }>;
60
54
  }
55
+ export interface MemoryUsage {
56
+ rss: number;
57
+ heapTotal: number;
58
+ heapUsed: number;
59
+ external: number;
60
+ arrayBuffers: number;
61
+ }
61
62
  export type ExecutionFrame = ({
62
63
  invokedByExecutionJWT: string;
63
64
  invokedByExecutionStartedAt: string;
@@ -40,4 +40,6 @@ export interface TriggerPayload {
40
40
  flow: FlowAttributes;
41
41
  /** The time in UTC that execution started. */
42
42
  startedAt: string;
43
+ /** Determines whether the execution will run in debug mode. */
44
+ globalDebug: boolean;
43
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.3.11",
3
+ "version": "10.3.13",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",