@cparra/apex-reflection 2.23.1 → 2.23.2

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -41,9 +41,9 @@ function resolveNativeBinaryPath() {
41
41
  }
42
42
  throw new Error(`Native binary not found. Expected one of:\n- ${downloadedPath}\n- ${devBuiltPath}\n\nIf you just installed this package, ensure postinstall succeeded.\nIf you're developing locally, run the dev build to create the host binary.`);
43
43
  }
44
- function reflectFor(type, declarationBody) {
44
+ function reflect(declarationBody) {
45
45
  const binaryPath = resolveNativeBinaryPath();
46
- const result = (0, child_process_1.spawnSync)(binaryPath, [`--type=${type}`], {
46
+ const result = (0, child_process_1.spawnSync)(binaryPath, ["--type=reflectType"], {
47
47
  input: declarationBody,
48
48
  encoding: "utf8",
49
49
  maxBuffer: 1024 * 1024 * 50,
@@ -58,10 +58,6 @@ function reflectFor(type, declarationBody) {
58
58
  if (!stdout) {
59
59
  throw new Error("apex-reflection native binary produced no output on stdout.");
60
60
  }
61
- return stdout;
62
- }
63
- function reflect(declarationBody) {
64
- const stdout = reflectFor("reflectType", declarationBody);
65
61
  try {
66
62
  return JSON.parse(stdout);
67
63
  }
@@ -71,7 +67,22 @@ function reflect(declarationBody) {
71
67
  }
72
68
  exports.reflect = reflect;
73
69
  function reflectTrigger(declarationBody) {
74
- const stdout = reflectFor("reflectTrigger", declarationBody);
70
+ const binaryPath = resolveNativeBinaryPath();
71
+ const result = (0, child_process_1.spawnSync)(binaryPath, ["--type=reflectTrigger"], {
72
+ input: declarationBody,
73
+ encoding: "utf8",
74
+ maxBuffer: 1024 * 1024 * 50,
75
+ });
76
+ if (result.error) {
77
+ throw new Error(`apex-reflection native binary failed to start. error:\n${String(result.error)}`);
78
+ }
79
+ if (result.status !== 0) {
80
+ throw new Error(`apex-reflection native binary failed (code=${result.status}). stderr:\n${result.stderr ?? ""}`);
81
+ }
82
+ const stdout = (result.stdout ?? "").toString().trim();
83
+ if (!stdout) {
84
+ throw new Error("apex-reflection native binary produced no output on stdout.");
85
+ }
75
86
  try {
76
87
  return JSON.parse(stdout);
77
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cparra/apex-reflection",
3
- "version": "2.23.1",
3
+ "version": "2.23.2",
4
4
  "description": "Provides tools for reflecting Apex code, the language used in Salesforce development.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {