@cparra/apex-reflection 2.22.0-dev.20251224082625 → 2.22.0
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.d.ts +4 -1
- package/dist/index.js +20 -57
- package/dist/out.d.ts +3 -0
- package/dist/out.js +31506 -0
- package/package.json +3 -15
- package/publish-scripts/postinstall.js +0 -199
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export declare function reflect(declarationBody: string):
|
|
1
|
+
export declare function reflect(declarationBody: string): ReflectionResult;
|
|
2
|
+
export declare function reflectAsync(declarationBody: string): Promise<ReflectionResult>;
|
|
3
|
+
export declare function reflectTrigger(declarationBody: string): TriggerReflectionResult;
|
|
4
|
+
export declare function reflectTriggerAsync(declarationBody: string): Promise<TriggerReflectionResult>;
|
|
2
5
|
export interface ParamAnnotation {
|
|
3
6
|
bodyLines: string[];
|
|
4
7
|
paramName: string;
|
package/dist/index.js
CHANGED
|
@@ -1,62 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.reflect = void 0;
|
|
7
|
-
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
function resolveNativeBinaryPath() {
|
|
11
|
-
const platform = process.platform;
|
|
12
|
-
const arch = process.arch;
|
|
13
|
-
let folderName;
|
|
14
|
-
if (platform === "darwin" && arch === "arm64") {
|
|
15
|
-
folderName = "darwin-arm64";
|
|
16
|
-
}
|
|
17
|
-
else if (platform === "darwin" && arch === "x64") {
|
|
18
|
-
folderName = "darwin-x64";
|
|
19
|
-
}
|
|
20
|
-
else if (platform === "linux" && arch === "x64") {
|
|
21
|
-
folderName = "linux-x64";
|
|
22
|
-
}
|
|
23
|
-
else if (platform === "win32" && arch === "x64") {
|
|
24
|
-
folderName = "windows-x64";
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
throw new Error(`Unsupported platform/arch combination: ${platform}/${arch}`);
|
|
28
|
-
}
|
|
29
|
-
const fileName = platform === "win32" ? "apex-reflection.exe" : "apex-reflection";
|
|
30
|
-
// At runtime, this file is `dist/index.js`, so `__dirname` points to `dist/`.
|
|
31
|
-
// postinstall installs to: dist/native/<platform-arch>/<fileName>
|
|
32
|
-
const downloadedPath = path_1.default.join(__dirname, "native", folderName, fileName);
|
|
33
|
-
// dev flow builds to: dist/native/<platform-arch>/<fileName>
|
|
34
|
-
// (same place), but keep this explicit so we can evolve paths later.
|
|
35
|
-
const devBuiltPath = downloadedPath;
|
|
36
|
-
if (fs_1.default.existsSync(downloadedPath)) {
|
|
37
|
-
return downloadedPath;
|
|
38
|
-
}
|
|
39
|
-
if (fs_1.default.existsSync(devBuiltPath)) {
|
|
40
|
-
return devBuiltPath;
|
|
41
|
-
}
|
|
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
|
-
}
|
|
3
|
+
exports.reflectTriggerAsync = exports.reflectTrigger = exports.reflectAsync = exports.reflect = void 0;
|
|
4
|
+
require("./out.js");
|
|
44
5
|
function reflect(declarationBody) {
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
const execResult = shelljs_1.default.exec(`"${binaryPath}" --type=reflectType --source "${declarationBody}"`, { silent: true });
|
|
48
|
-
if (execResult.code !== 0) {
|
|
49
|
-
throw new Error(`apex-reflection native binary failed (code=${execResult.code}). stderr:\n${execResult.stderr}`);
|
|
50
|
-
}
|
|
51
|
-
const stdout = (execResult.stdout ?? "").toString().trim();
|
|
52
|
-
if (!stdout) {
|
|
53
|
-
throw new Error("apex-reflection native binary produced no output on stdout.");
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
return JSON.parse(stdout);
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
throw new Error(`apex-reflection native binary output was not valid JSON.\nstdout:\n${stdout}\nerror: ${String(e)}`);
|
|
60
|
-
}
|
|
6
|
+
// @ts-expect-error "reflect" is added to self by the "out" module
|
|
7
|
+
return JSON.parse(self.reflect(declarationBody));
|
|
61
8
|
}
|
|
62
9
|
exports.reflect = reflect;
|
|
10
|
+
async function reflectAsync(declarationBody) {
|
|
11
|
+
// @ts-expect-error "reflectAsync" is added to self by the "out" module
|
|
12
|
+
const result = await self.reflectAsync(declarationBody);
|
|
13
|
+
return JSON.parse(result);
|
|
14
|
+
}
|
|
15
|
+
exports.reflectAsync = reflectAsync;
|
|
16
|
+
function reflectTrigger(declarationBody) {
|
|
17
|
+
// @ts-expect-error "reflectTrigger" is added to self by the "out" module
|
|
18
|
+
return JSON.parse(self.reflectTrigger(declarationBody));
|
|
19
|
+
}
|
|
20
|
+
exports.reflectTrigger = reflectTrigger;
|
|
21
|
+
function reflectTriggerAsync(declarationBody) {
|
|
22
|
+
// @ts-expect-error "reflectTriggerAsync" is added to self by the "out" module
|
|
23
|
+
return self.reflectTriggerAsync(declarationBody).then((result) => JSON.parse(result));
|
|
24
|
+
}
|
|
25
|
+
exports.reflectTriggerAsync = reflectTriggerAsync;
|
package/dist/out.d.ts
ADDED