@cparra/apex-reflection 2.24.4 → 3.0.0-dev.20260614084225

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/package.json CHANGED
@@ -1,19 +1,15 @@
1
1
  {
2
2
  "name": "@cparra/apex-reflection",
3
- "version": "2.24.4",
3
+ "version": "3.0.0-dev.20260614084225",
4
4
  "description": "Provides tools for reflecting Apex code, the language used in Salesforce development.",
5
- "main": "dist/index.js",
5
+ "main": "dist/index.mjs",
6
6
  "scripts": {
7
7
  "clean": "rimraf dist",
8
- "build": "npm run clean && tsc && node scripts/copy-out-js-to-dist.js",
9
- "postinstall": "node publish-scripts/postinstall.js",
10
- "dev:build": "npm run build && npm run dev:build:native:host && npm run dev:chmod:native:host",
11
- "dev:build:native:host": "node scripts/build-natives.js --host",
12
- "dev:chmod:native:host": "node scripts/dev-chmod-native-host.js",
8
+ "build": "npm run clean && tsc && node scripts/copy-node-wasm-to-dist.js",
9
+ "dev:build": "npm run build",
13
10
  "dev:version:prerelease": "node scripts/dev-bump-version-prerelease.js",
14
- "dev:github:release": "node scripts/dev-github-release.js",
15
11
  "dev:publish": "node scripts/dev-publish.js",
16
- "test": "jest"
12
+ "test": "npm run build && node --test \"__tests__/**/*.test.mts\""
17
13
  },
18
14
  "keywords": [
19
15
  "apex",
@@ -25,20 +21,18 @@
25
21
  "author": "Cesar Parra",
26
22
  "license": "ISC",
27
23
  "devDependencies": {
28
- "@types/jest": "^27.5.2",
29
- "@types/node": "^16.18.98",
30
- "@types/typescript": "^2.0.0",
31
- "jest": "^27.2.4",
24
+ "@types/node": "^25.9.3",
32
25
  "rimraf": "^6.0.1",
33
- "ts-jest": "^27.0.5",
34
- "typescript": "^4.7.4"
26
+ "typescript": "^6.0.3"
35
27
  },
36
- "types": "dist/index.d.ts",
28
+ "types": "dist/index.d.mts",
37
29
  "files": [
38
- "dist/index.js",
39
- "dist/index.d.ts",
40
- "dist/out.js",
41
- "publish-scripts/postinstall.js",
42
- "out.js"
43
- ]
30
+ "dist/index.mjs",
31
+ "dist/index.d.mts",
32
+ "dist/node.mjs",
33
+ "dist/node.wasm"
34
+ ],
35
+ "engines": {
36
+ "node": ">=22.0.0"
37
+ }
44
38
  }
package/dist/index.js DELETED
@@ -1,145 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.reflectTriggerAsync = exports.reflectAsync = exports.reflectTrigger = exports.reflect = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const child_process_1 = require("child_process");
10
- let _outJs = null;
11
- function getOutJs() {
12
- if (_outJs)
13
- return _outJs;
14
- require("./out.js");
15
- const g = globalThis;
16
- const selfObj = g?.self ?? g;
17
- _outJs = {
18
- reflect: selfObj?.reflect,
19
- reflectAsync: selfObj?.reflectAsync,
20
- reflectTrigger: selfObj?.reflectTrigger,
21
- reflectTriggerAsync: selfObj?.reflectTriggerAsync,
22
- };
23
- return _outJs;
24
- }
25
- function resolveNativeBinaryPath() {
26
- const platform = process.platform;
27
- const arch = process.arch;
28
- let folderName;
29
- if (platform === "darwin" && arch === "arm64") {
30
- folderName = "darwin-arm64";
31
- }
32
- else if (platform === "darwin" && arch === "x64") {
33
- folderName = "darwin-x64";
34
- }
35
- else if (platform === "linux" && arch === "x64") {
36
- folderName = "linux-x64";
37
- }
38
- else if (platform === "win32" && arch === "x64") {
39
- folderName = "windows-x64";
40
- }
41
- else if (platform === "win32" && arch === "arm64") {
42
- folderName = "windows-arm64";
43
- }
44
- else {
45
- throw new Error(`Unsupported platform/arch combination: ${platform}/${arch}`);
46
- }
47
- const fileName = platform === "win32" ? "apex-reflection.exe" : "apex-reflection";
48
- // At runtime, this file is `dist/index.js`, so `__dirname` points to `dist/`.
49
- // postinstall installs to: dist/native/<platform-arch>/<fileName>
50
- const downloadedPath = path_1.default.join(__dirname, "native", folderName, fileName);
51
- // dev flow builds to: dist/native/<platform-arch>/<fileName>
52
- // (same place), but keep this explicit so we can evolve paths later.
53
- const devBuiltPath = downloadedPath;
54
- if (fs_1.default.existsSync(downloadedPath))
55
- return downloadedPath;
56
- if (fs_1.default.existsSync(devBuiltPath))
57
- return devBuiltPath;
58
- 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.`);
59
- }
60
- function hasNativeBinary() {
61
- try {
62
- resolveNativeBinaryPath();
63
- return true;
64
- }
65
- catch {
66
- return false;
67
- }
68
- }
69
- function reflectFor(type, declarationBody) {
70
- const binaryPath = resolveNativeBinaryPath();
71
- const result = (0, child_process_1.spawnSync)(binaryPath, [`--type=${type}`], {
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
- }
86
- return stdout;
87
- }
88
- function reflect(declarationBody) {
89
- if (!hasNativeBinary()) {
90
- const self = getOutJs();
91
- if (!self.reflect) {
92
- throw new Error("Native binary not found and out.js fallback does not export `reflect`.");
93
- }
94
- return JSON.parse(self.reflect(declarationBody));
95
- }
96
- const stdout = reflectFor("reflectType", declarationBody);
97
- try {
98
- return JSON.parse(stdout);
99
- }
100
- catch (e) {
101
- throw new Error(`apex-reflection native binary output was not valid JSON.\nstdout:\n${stdout}\nerror: ${String(e)}`);
102
- }
103
- }
104
- exports.reflect = reflect;
105
- function reflectTrigger(declarationBody) {
106
- if (!hasNativeBinary()) {
107
- const self = getOutJs();
108
- if (!self.reflectTrigger) {
109
- throw new Error("Native binary not found and out.js fallback does not export `reflectTrigger`.");
110
- }
111
- return JSON.parse(self.reflectTrigger(declarationBody));
112
- }
113
- const stdout = reflectFor("reflectTrigger", declarationBody);
114
- try {
115
- return JSON.parse(stdout);
116
- }
117
- catch (e) {
118
- throw new Error(`apex-reflection native binary output was not valid JSON.\nstdout:\n${stdout}\nerror: ${String(e)}`);
119
- }
120
- }
121
- exports.reflectTrigger = reflectTrigger;
122
- async function reflectAsync(declarationBody) {
123
- if (!hasNativeBinary()) {
124
- const self = getOutJs();
125
- if (!self.reflectAsync) {
126
- throw new Error("Native binary not found and out.js fallback does not export `reflectAsync`.");
127
- }
128
- return JSON.parse(await self.reflectAsync(declarationBody));
129
- }
130
- // Native binary path is sync (spawnSync). Keep API available by resolving immediately.
131
- return reflect(declarationBody);
132
- }
133
- exports.reflectAsync = reflectAsync;
134
- async function reflectTriggerAsync(declarationBody) {
135
- if (!hasNativeBinary()) {
136
- const self = getOutJs();
137
- if (!self.reflectTriggerAsync) {
138
- throw new Error("Native binary not found and out.js fallback does not export `reflectTriggerAsync`.");
139
- }
140
- return JSON.parse(await self.reflectTriggerAsync(declarationBody));
141
- }
142
- // Native binary path is sync (spawnSync). Keep API available by resolving immediately.
143
- return reflectTrigger(declarationBody);
144
- }
145
- exports.reflectTriggerAsync = reflectTriggerAsync;