@c9up/eon 0.2.8 → 0.2.9
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/EonProvider.d.ts +10 -0
- package/dist/EonProvider.d.ts.map +1 -1
- package/dist/EonProvider.js +14 -0
- package/dist/EonProvider.js.map +1 -1
- package/dist/query/native.d.ts.map +1 -1
- package/dist/query/native.js +11 -27
- package/dist/query/native.js.map +1 -1
- package/dist/vendor/nativeBinary.d.ts +43 -0
- package/dist/vendor/nativeBinary.d.ts.map +1 -0
- package/dist/vendor/nativeBinary.js +99 -0
- package/dist/vendor/nativeBinary.js.map +1 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +3 -2
- package/src/EonProvider.ts +25 -0
- package/src/query/native.ts +18 -31
- package/src/vendor/nativeBinary.ts +110 -0
package/dist/EonProvider.d.ts
CHANGED
|
@@ -34,6 +34,16 @@ export interface EonAppContext {
|
|
|
34
34
|
config: {
|
|
35
35
|
get<T = unknown>(key: string): T | undefined;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Optional reader — present on ream's real application.
|
|
39
|
+
*
|
|
40
|
+
* `'warmup'` means the application was assembled to be INSPECTED rather than
|
|
41
|
+
* run: a route listing, a codegen pass, a config dump. Providers register,
|
|
42
|
+
* boot and start on that path too, so anything that opens a socket or
|
|
43
|
+
* creates a database has to ask first. A host that does not implement it is
|
|
44
|
+
* treated as running.
|
|
45
|
+
*/
|
|
46
|
+
getMode?(): string;
|
|
37
47
|
}
|
|
38
48
|
/**
|
|
39
49
|
* The transport-independent compiler service registered under `eon.compiler`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EonProvider.d.ts","sourceRoot":"","sources":["../src/EonProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAa,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,O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OAAO,CAAC,CACP,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,GAC1D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;KAC9B,CAAC;IACF,MAAM,EAAE;QAAE,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAA;KAAE,CAAC;IACzD;;;;;;;;OAQG;IACH,OAAO,CAAC,IAAI,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC;CAC/D;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAC1B,MAAM,EAAE,mBAAmB,KACvB,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,qBAAa,WAAW;;gBAQX,GAAG,EAAE,aAAa,EAAE,OAAO,GAAE,YAA2B;IAKpE,QAAQ,IAAI,IAAI;IAOV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA6IrB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAgF/B;AAID,eAAe,WAAW,CAAC"}
|
package/dist/EonProvider.js
CHANGED
|
@@ -27,7 +27,15 @@ export class EonProvider {
|
|
|
27
27
|
this.#connect = connect;
|
|
28
28
|
}
|
|
29
29
|
register() { }
|
|
30
|
+
/** True when the application was assembled to be inspected rather than run. */
|
|
31
|
+
#isInspecting() {
|
|
32
|
+
return this.#app.getMode?.() === "warmup";
|
|
33
|
+
}
|
|
30
34
|
async boot() {
|
|
35
|
+
// An inspection opens no WebSocket and creates no database. `warmUp()`
|
|
36
|
+
// runs boot, so a route listing reached TDengine — and could CREATE a
|
|
37
|
+
// database there — while `shutdown()` never fires on that path, leaving
|
|
38
|
+
// the sockets open. The compiler binding below is pure and stays.
|
|
31
39
|
if (this.#booted) {
|
|
32
40
|
throw new Error("EonProvider: boot() has already opened connections; a second boot would overwrite and leak them. Call shutdown() first, or construct a new provider.");
|
|
33
41
|
}
|
|
@@ -36,6 +44,12 @@ export class EonProvider {
|
|
|
36
44
|
compile: (spec, dialect) => compileStatementNative(spec, dialect),
|
|
37
45
|
};
|
|
38
46
|
this.#app.container.singleton("eon.compiler", () => service);
|
|
47
|
+
// Everything past here opens a socket or creates a database, so an
|
|
48
|
+
// inspection stops at the compiler. `warmUp()` runs boot, so a route
|
|
49
|
+
// listing reached TDengine — and could CREATE a database there — while
|
|
50
|
+
// `shutdown()` never fires on that path, leaving the sockets open.
|
|
51
|
+
if (this.#isInspecting())
|
|
52
|
+
return;
|
|
39
53
|
const config = this.#app.config.get("timeseries") ??
|
|
40
54
|
this.#app.config.get("eon");
|
|
41
55
|
if (!config)
|
package/dist/EonProvider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EonProvider.js","sourceRoot":"","sources":["../src/EonProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,oBAAoB,CAAC;AAG5B,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAEN,sBAAsB,GAEtB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"EonProvider.js","sourceRoot":"","sources":["../src/EonProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,oBAAoB,CAAC;AAG5B,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAEN,sBAAsB,GAEtB,MAAM,mBAAmB,CAAC;AAoD3B,MAAM,OAAO,WAAW;IACd,IAAI,CAAgB;IACpB,QAAQ,CAAe;IAChC,4DAA4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GAAG;oBACf,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,cAAc,EAAE,MAAM,CAAC,cAAc;oBACrC,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,SAAS,EAAE,MAAM,CAAC,SAAS;oBAC3B,cAAc,EAAE,MAAM,CAAC,cAAc;oBACrC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;iBACzC;aACD;YACD,WAAW,EAAE,SAAS;SACtB,CAAC;IACH,CAAC;CACD;AAED,0EAA0E;AAC1E,2EAA2E;AAC3E,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/query/native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/query/native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,sEAAsE;AACtE,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AAEpC,MAAM,WAAW,iBAAiB;IACjC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,OAAO,EAAE,CAAC;CAClB;AA0HD;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,UAAuB,GAC9B,iBAAiB,CAKnB;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
package/dist/query/native.js
CHANGED
|
@@ -7,19 +7,7 @@
|
|
|
7
7
|
* throws a descriptive error naming the attempted path — never a silent `null`.
|
|
8
8
|
*/
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
|
-
import {
|
|
11
|
-
import { dirname, join } from "node:path";
|
|
12
|
-
import { arch, platform } from "node:process";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
14
|
-
const require2 = createRequire(import.meta.url);
|
|
15
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
const platformMap = {
|
|
17
|
-
"linux-x64": "linux-x64-gnu",
|
|
18
|
-
"linux-arm64": "linux-arm64-gnu",
|
|
19
|
-
"darwin-x64": "darwin-x64",
|
|
20
|
-
"darwin-arm64": "darwin-arm64",
|
|
21
|
-
"win32-x64": "win32-x64-msvc",
|
|
22
|
-
};
|
|
10
|
+
import { loadNativeBinary, muslHint, supportedTargets, } from "../vendor/nativeBinary.js";
|
|
23
11
|
let native;
|
|
24
12
|
/**
|
|
25
13
|
* Resolve and cache the NAPI binding. Throws a descriptive error on an
|
|
@@ -30,21 +18,17 @@ let native;
|
|
|
30
18
|
function loadNative() {
|
|
31
19
|
if (native)
|
|
32
20
|
return native;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
binding = require2(binaryPath);
|
|
42
|
-
}
|
|
43
|
-
catch (cause) {
|
|
44
|
-
throw new Error(`[E_EON_NAPI_NOT_FOUND] eon-query native binary not found at '${binaryPath}'. Build it with: pnpm --filter @c9up/eon build:napi`, cause !== undefined ? { cause } : undefined);
|
|
21
|
+
// The resolution is shared; the refusal is not. Both codes below are eon's,
|
|
22
|
+
// and a caller branches on them.
|
|
23
|
+
const attempt = loadNativeBinary();
|
|
24
|
+
if (!attempt.loaded) {
|
|
25
|
+
if (attempt.suffix === undefined) {
|
|
26
|
+
throw new Error(`[E_EON_NAPI_UNSUPPORTED] no eon-query native binary for this platform. Supported: ${supportedTargets().join(", ")}.`);
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`[E_EON_NAPI_NOT_FOUND] eon-query native binary 'index.${attempt.suffix}.node' not found or unloadable.${muslHint()} Build it with: pnpm --filter @c9up/eon build:napi`, attempt.cause !== undefined ? { cause: attempt.cause } : undefined);
|
|
45
29
|
}
|
|
46
|
-
native =
|
|
47
|
-
return
|
|
30
|
+
native = attempt.binary;
|
|
31
|
+
return attempt.binary;
|
|
48
32
|
}
|
|
49
33
|
/**
|
|
50
34
|
* i64 / nanosecond-timestamp precision guard for the JSON compile boundary.
|
package/dist/query/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/query/native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/query/native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,GAChB,MAAM,2BAA2B,CAAC;AAmBnC,IAAI,MAAiC,CAAC;AAEtC;;;;;GAKG;AACH,SAAS,UAAU;IAClB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,4EAA4E;IAC5E,iCAAiC;IACjC,MAAM,OAAO,GAAG,gBAAgB,EAAiB,CAAC;IAClD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACd,qFAAqF,gBAAgB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACrH,CAAC;QACH,CAAC;QACD,MAAM,IAAI,KAAK,CACd,yDAAyD,OAAO,CAAC,MAAM,kCAAkC,QAAQ,EAAE,oDAAoD,EACvK,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAClE,CAAC;IACH,CAAC;IACD,MAAM,GAAG,OAAO,CAAC,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CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,UAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every `platform-arch` a binary is built for.
|
|
3
|
+
*
|
|
4
|
+
* For the message a package raises when it refuses: "no binary for
|
|
5
|
+
* linux-riscv64" is only actionable next to the list of what there IS.
|
|
6
|
+
*/
|
|
7
|
+
export declare function supportedTargets(): readonly string[];
|
|
8
|
+
/** The suffix a given `platform-arch` builds under, or `undefined`. */
|
|
9
|
+
export declare function nativeTargetSuffix(target: string): string | undefined;
|
|
10
|
+
/** The suffix for THIS platform, or `undefined` where no binary is built. */
|
|
11
|
+
export declare function nativeBinarySuffix(): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Why the binary is not there, phrased for whoever has to fix it.
|
|
14
|
+
*
|
|
15
|
+
* "not found" and "not built for your platform" call for different actions,
|
|
16
|
+
* and a single "unavailable" leaves the reader to guess which one they are
|
|
17
|
+
* looking at.
|
|
18
|
+
*/
|
|
19
|
+
export declare function unavailableReason(cause?: unknown): string;
|
|
20
|
+
/**
|
|
21
|
+
* `musl` builds under a different suffix, and the failure is otherwise
|
|
22
|
+
* baffling: the file is there, and `require` still refuses it. Worth saying so
|
|
23
|
+
* in a message rather than leaving a reader to discover glibc.
|
|
24
|
+
*/
|
|
25
|
+
export declare function muslHint(): string;
|
|
26
|
+
/** What a load attempt did, so the caller can apply its own policy. */
|
|
27
|
+
export type NativeBinaryResult<T> = {
|
|
28
|
+
loaded: true;
|
|
29
|
+
binary: T;
|
|
30
|
+
} | {
|
|
31
|
+
loaded: false;
|
|
32
|
+
suffix: string | undefined;
|
|
33
|
+
cause?: unknown;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Load `<package root>/index.<suffix>.node`.
|
|
37
|
+
*
|
|
38
|
+
* The path is fixed rather than passed: this file is generated into
|
|
39
|
+
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
40
|
+
* `src` and from `dist` alike.
|
|
41
|
+
*/
|
|
42
|
+
export declare function loadNativeBinary<T>(): NativeBinaryResult<T>;
|
|
43
|
+
//# sourceMappingURL=nativeBinary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeBinary.d.ts","sourceRoot":"","sources":["../../src/vendor/nativeBinary.ts"],"names":[],"mappings":"AAoCA;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,SAAS,MAAM,EAAE,CAEpD;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErE;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAEvD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAQzD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAIjC;AAED,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAC7B;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GAC3B;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAElE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAa3D"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Generated from scripts/vendor/nativeBinary.ts — do not edit.
|
|
2
|
+
//
|
|
3
|
+
// This package is published and built from its own repository, so the file
|
|
4
|
+
// has to exist here rather than be imported. `pnpm vendor:sync` rewrites it,
|
|
5
|
+
// and `pnpm vendor:check` fails if this copy has drifted from the original.
|
|
6
|
+
/**
|
|
7
|
+
* Finding the NAPI binary a package ships beside itself.
|
|
8
|
+
*
|
|
9
|
+
* Every package with a Rust engine repeats the same table: napi-rs names its
|
|
10
|
+
* artefacts `index.<platform>-<arch>-<abi>.node`, and the mapping from Node's
|
|
11
|
+
* `platform`/`arch` to that suffix is the part that must never differ between
|
|
12
|
+
* packages. Adding a target means adding it everywhere, and a package that
|
|
13
|
+
* missed the edit fails only on that platform — which is exactly the failure
|
|
14
|
+
* nobody reproduces.
|
|
15
|
+
*
|
|
16
|
+
* What is NOT here is the policy. Some packages degrade when the binary is
|
|
17
|
+
* absent and answer `undefined`; others refuse loudly with build instructions.
|
|
18
|
+
* Both are right for their package, so the loader reports what happened and
|
|
19
|
+
* the caller decides.
|
|
20
|
+
*/
|
|
21
|
+
import { createRequire } from "node:module";
|
|
22
|
+
import { dirname, join } from "node:path";
|
|
23
|
+
import { arch, platform } from "node:process";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
/** Node's `platform-arch` → the suffix napi-rs builds under. */
|
|
26
|
+
const TARGETS = {
|
|
27
|
+
"linux-x64": "linux-x64-gnu",
|
|
28
|
+
"linux-arm64": "linux-arm64-gnu",
|
|
29
|
+
"darwin-x64": "darwin-x64",
|
|
30
|
+
"darwin-arm64": "darwin-arm64",
|
|
31
|
+
"win32-x64": "win32-x64-msvc",
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Every `platform-arch` a binary is built for.
|
|
35
|
+
*
|
|
36
|
+
* For the message a package raises when it refuses: "no binary for
|
|
37
|
+
* linux-riscv64" is only actionable next to the list of what there IS.
|
|
38
|
+
*/
|
|
39
|
+
export function supportedTargets() {
|
|
40
|
+
return Object.keys(TARGETS);
|
|
41
|
+
}
|
|
42
|
+
/** The suffix a given `platform-arch` builds under, or `undefined`. */
|
|
43
|
+
export function nativeTargetSuffix(target) {
|
|
44
|
+
return TARGETS[target];
|
|
45
|
+
}
|
|
46
|
+
/** The suffix for THIS platform, or `undefined` where no binary is built. */
|
|
47
|
+
export function nativeBinarySuffix() {
|
|
48
|
+
return nativeTargetSuffix(`${platform}-${arch}`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Why the binary is not there, phrased for whoever has to fix it.
|
|
52
|
+
*
|
|
53
|
+
* "not found" and "not built for your platform" call for different actions,
|
|
54
|
+
* and a single "unavailable" leaves the reader to guess which one they are
|
|
55
|
+
* looking at.
|
|
56
|
+
*/
|
|
57
|
+
export function unavailableReason(cause) {
|
|
58
|
+
if (cause !== undefined) {
|
|
59
|
+
return `failed to load (${cause instanceof Error ? cause.message : String(cause)})`;
|
|
60
|
+
}
|
|
61
|
+
const target = `${platform}-${arch}`;
|
|
62
|
+
return nativeTargetSuffix(target) !== undefined
|
|
63
|
+
? "binary not found"
|
|
64
|
+
: `no prebuilt binary for ${target}`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `musl` builds under a different suffix, and the failure is otherwise
|
|
68
|
+
* baffling: the file is there, and `require` still refuses it. Worth saying so
|
|
69
|
+
* in a message rather than leaving a reader to discover glibc.
|
|
70
|
+
*/
|
|
71
|
+
export function muslHint() {
|
|
72
|
+
return platform === "linux"
|
|
73
|
+
? " On Alpine/musl, the gnu binary will not load — build the musl target."
|
|
74
|
+
: "";
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Load `<package root>/index.<suffix>.node`.
|
|
78
|
+
*
|
|
79
|
+
* The path is fixed rather than passed: this file is generated into
|
|
80
|
+
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
81
|
+
* `src` and from `dist` alike.
|
|
82
|
+
*/
|
|
83
|
+
export function loadNativeBinary() {
|
|
84
|
+
const suffix = nativeBinarySuffix();
|
|
85
|
+
if (suffix === undefined)
|
|
86
|
+
return { loaded: false, suffix };
|
|
87
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
88
|
+
try {
|
|
89
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
90
|
+
return {
|
|
91
|
+
loaded: true,
|
|
92
|
+
binary: nodeRequire(join(here, `../../index.${suffix}.node`)),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (cause) {
|
|
96
|
+
return { loaded: false, suffix, cause };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=nativeBinary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeBinary.js","sourceRoot":"","sources":["../../src/vendor/nativeBinary.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,4EAA4E;AAE5E;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,gEAAgE;AAChE,MAAM,OAAO,GAA2B;IACvC,WAAW,EAAE,eAAe;IAC5B,aAAa,EAAE,iBAAiB;IAChC,YAAY,EAAE,YAAY;IAC1B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,gBAAgB;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAChD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,kBAAkB;IACjC,OAAO,kBAAkB,CAAC,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBA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
1
1
|
{
|
|
2
2
|
"name": "@c9up/eon",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Eon — time-series data layer for the Ream framework (TDengine-backed)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@biomejs/biome": "^2.4.10",
|
|
61
61
|
"@types/node": "^22",
|
|
62
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
62
63
|
"tsx": "^4.19.0",
|
|
63
64
|
"typescript": "^6.0.2",
|
|
64
65
|
"vitest": "^4.1.2",
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
"build:napi-types": "node scripts/build-napi-types.mjs",
|
|
94
95
|
"test": "vitest run",
|
|
95
96
|
"test:rust": "cargo test -p eon-query",
|
|
96
|
-
"lint": "biome check src/",
|
|
97
|
+
"lint": "biome check src/ tests/",
|
|
97
98
|
"test:coverage": "vitest run --coverage",
|
|
98
99
|
"typecheck": "tsc --noEmit"
|
|
99
100
|
}
|
package/src/EonProvider.ts
CHANGED
|
@@ -45,6 +45,16 @@ export interface EonAppContext {
|
|
|
45
45
|
): unknown | Promise<unknown>;
|
|
46
46
|
};
|
|
47
47
|
config: { get<T = unknown>(key: string): T | undefined };
|
|
48
|
+
/**
|
|
49
|
+
* Optional reader — present on ream's real application.
|
|
50
|
+
*
|
|
51
|
+
* `'warmup'` means the application was assembled to be INSPECTED rather than
|
|
52
|
+
* run: a route listing, a codegen pass, a config dump. Providers register,
|
|
53
|
+
* boot and start on that path too, so anything that opens a socket or
|
|
54
|
+
* creates a database has to ask first. A host that does not implement it is
|
|
55
|
+
* treated as running.
|
|
56
|
+
*/
|
|
57
|
+
getMode?(): string;
|
|
48
58
|
}
|
|
49
59
|
|
|
50
60
|
/**
|
|
@@ -78,7 +88,16 @@ export class EonProvider {
|
|
|
78
88
|
|
|
79
89
|
register(): void {}
|
|
80
90
|
|
|
91
|
+
/** True when the application was assembled to be inspected rather than run. */
|
|
92
|
+
#isInspecting(): boolean {
|
|
93
|
+
return this.#app.getMode?.() === "warmup";
|
|
94
|
+
}
|
|
95
|
+
|
|
81
96
|
async boot(): Promise<void> {
|
|
97
|
+
// An inspection opens no WebSocket and creates no database. `warmUp()`
|
|
98
|
+
// runs boot, so a route listing reached TDengine — and could CREATE a
|
|
99
|
+
// database there — while `shutdown()` never fires on that path, leaving
|
|
100
|
+
// the sockets open. The compiler binding below is pure and stays.
|
|
82
101
|
if (this.#booted) {
|
|
83
102
|
throw new Error(
|
|
84
103
|
"EonProvider: boot() has already opened connections; a second boot would overwrite and leak them. Call shutdown() first, or construct a new provider.",
|
|
@@ -90,6 +109,12 @@ export class EonProvider {
|
|
|
90
109
|
};
|
|
91
110
|
this.#app.container.singleton("eon.compiler", () => service);
|
|
92
111
|
|
|
112
|
+
// Everything past here opens a socket or creates a database, so an
|
|
113
|
+
// inspection stops at the compiler. `warmUp()` runs boot, so a route
|
|
114
|
+
// listing reached TDengine — and could CREATE a database there — while
|
|
115
|
+
// `shutdown()` never fires on that path, leaving the sockets open.
|
|
116
|
+
if (this.#isInspecting()) return;
|
|
117
|
+
|
|
93
118
|
const config =
|
|
94
119
|
this.#app.config.get<EonConfig>("timeseries") ??
|
|
95
120
|
this.#app.config.get<EonConfig>("eon");
|
package/src/query/native.ts
CHANGED
|
@@ -8,21 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const require2 = createRequire(import.meta.url);
|
|
17
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
|
|
19
|
-
const platformMap: Record<string, string> = {
|
|
20
|
-
"linux-x64": "linux-x64-gnu",
|
|
21
|
-
"linux-arm64": "linux-arm64-gnu",
|
|
22
|
-
"darwin-x64": "darwin-x64",
|
|
23
|
-
"darwin-arm64": "darwin-arm64",
|
|
24
|
-
"win32-x64": "win32-x64-msvc",
|
|
25
|
-
};
|
|
11
|
+
import {
|
|
12
|
+
loadNativeBinary,
|
|
13
|
+
muslHint,
|
|
14
|
+
supportedTargets,
|
|
15
|
+
} from "../vendor/nativeBinary.js";
|
|
26
16
|
|
|
27
17
|
/**
|
|
28
18
|
* The compiler's surface, as the Rust declares it.
|
|
@@ -51,25 +41,22 @@ let native: NativeBinding | undefined;
|
|
|
51
41
|
*/
|
|
52
42
|
function loadNative(): NativeBinding {
|
|
53
43
|
if (native) return native;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
binding = require2(binaryPath);
|
|
65
|
-
} catch (cause) {
|
|
44
|
+
// The resolution is shared; the refusal is not. Both codes below are eon's,
|
|
45
|
+
// and a caller branches on them.
|
|
46
|
+
const attempt = loadNativeBinary<NativeBinding>();
|
|
47
|
+
if (!attempt.loaded) {
|
|
48
|
+
if (attempt.suffix === undefined) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`[E_EON_NAPI_UNSUPPORTED] no eon-query native binary for this platform. Supported: ${supportedTargets().join(", ")}.`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
66
53
|
throw new Error(
|
|
67
|
-
`[E_EON_NAPI_NOT_FOUND] eon-query native binary not found
|
|
68
|
-
cause !== undefined ? { cause } : undefined,
|
|
54
|
+
`[E_EON_NAPI_NOT_FOUND] eon-query native binary 'index.${attempt.suffix}.node' not found or unloadable.${muslHint()} Build it with: pnpm --filter @c9up/eon build:napi`,
|
|
55
|
+
attempt.cause !== undefined ? { cause: attempt.cause } : undefined,
|
|
69
56
|
);
|
|
70
57
|
}
|
|
71
|
-
native =
|
|
72
|
-
return
|
|
58
|
+
native = attempt.binary;
|
|
59
|
+
return attempt.binary;
|
|
73
60
|
}
|
|
74
61
|
|
|
75
62
|
/**
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Generated from scripts/vendor/nativeBinary.ts — do not edit.
|
|
2
|
+
//
|
|
3
|
+
// This package is published and built from its own repository, so the file
|
|
4
|
+
// has to exist here rather than be imported. `pnpm vendor:sync` rewrites it,
|
|
5
|
+
// and `pnpm vendor:check` fails if this copy has drifted from the original.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Finding the NAPI binary a package ships beside itself.
|
|
9
|
+
*
|
|
10
|
+
* Every package with a Rust engine repeats the same table: napi-rs names its
|
|
11
|
+
* artefacts `index.<platform>-<arch>-<abi>.node`, and the mapping from Node's
|
|
12
|
+
* `platform`/`arch` to that suffix is the part that must never differ between
|
|
13
|
+
* packages. Adding a target means adding it everywhere, and a package that
|
|
14
|
+
* missed the edit fails only on that platform — which is exactly the failure
|
|
15
|
+
* nobody reproduces.
|
|
16
|
+
*
|
|
17
|
+
* What is NOT here is the policy. Some packages degrade when the binary is
|
|
18
|
+
* absent and answer `undefined`; others refuse loudly with build instructions.
|
|
19
|
+
* Both are right for their package, so the loader reports what happened and
|
|
20
|
+
* the caller decides.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { createRequire } from "node:module";
|
|
24
|
+
import { dirname, join } from "node:path";
|
|
25
|
+
import { arch, platform } from "node:process";
|
|
26
|
+
import { fileURLToPath } from "node:url";
|
|
27
|
+
|
|
28
|
+
/** Node's `platform-arch` → the suffix napi-rs builds under. */
|
|
29
|
+
const TARGETS: Record<string, string> = {
|
|
30
|
+
"linux-x64": "linux-x64-gnu",
|
|
31
|
+
"linux-arm64": "linux-arm64-gnu",
|
|
32
|
+
"darwin-x64": "darwin-x64",
|
|
33
|
+
"darwin-arm64": "darwin-arm64",
|
|
34
|
+
"win32-x64": "win32-x64-msvc",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Every `platform-arch` a binary is built for.
|
|
39
|
+
*
|
|
40
|
+
* For the message a package raises when it refuses: "no binary for
|
|
41
|
+
* linux-riscv64" is only actionable next to the list of what there IS.
|
|
42
|
+
*/
|
|
43
|
+
export function supportedTargets(): readonly string[] {
|
|
44
|
+
return Object.keys(TARGETS);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The suffix a given `platform-arch` builds under, or `undefined`. */
|
|
48
|
+
export function nativeTargetSuffix(target: string): string | undefined {
|
|
49
|
+
return TARGETS[target];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The suffix for THIS platform, or `undefined` where no binary is built. */
|
|
53
|
+
export function nativeBinarySuffix(): string | undefined {
|
|
54
|
+
return nativeTargetSuffix(`${platform}-${arch}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Why the binary is not there, phrased for whoever has to fix it.
|
|
59
|
+
*
|
|
60
|
+
* "not found" and "not built for your platform" call for different actions,
|
|
61
|
+
* and a single "unavailable" leaves the reader to guess which one they are
|
|
62
|
+
* looking at.
|
|
63
|
+
*/
|
|
64
|
+
export function unavailableReason(cause?: unknown): string {
|
|
65
|
+
if (cause !== undefined) {
|
|
66
|
+
return `failed to load (${cause instanceof Error ? cause.message : String(cause)})`;
|
|
67
|
+
}
|
|
68
|
+
const target = `${platform}-${arch}`;
|
|
69
|
+
return nativeTargetSuffix(target) !== undefined
|
|
70
|
+
? "binary not found"
|
|
71
|
+
: `no prebuilt binary for ${target}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* `musl` builds under a different suffix, and the failure is otherwise
|
|
76
|
+
* baffling: the file is there, and `require` still refuses it. Worth saying so
|
|
77
|
+
* in a message rather than leaving a reader to discover glibc.
|
|
78
|
+
*/
|
|
79
|
+
export function muslHint(): string {
|
|
80
|
+
return platform === "linux"
|
|
81
|
+
? " On Alpine/musl, the gnu binary will not load — build the musl target."
|
|
82
|
+
: "";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** What a load attempt did, so the caller can apply its own policy. */
|
|
86
|
+
export type NativeBinaryResult<T> =
|
|
87
|
+
| { loaded: true; binary: T }
|
|
88
|
+
| { loaded: false; suffix: string | undefined; cause?: unknown };
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Load `<package root>/index.<suffix>.node`.
|
|
92
|
+
*
|
|
93
|
+
* The path is fixed rather than passed: this file is generated into
|
|
94
|
+
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
95
|
+
* `src` and from `dist` alike.
|
|
96
|
+
*/
|
|
97
|
+
export function loadNativeBinary<T>(): NativeBinaryResult<T> {
|
|
98
|
+
const suffix = nativeBinarySuffix();
|
|
99
|
+
if (suffix === undefined) return { loaded: false, suffix };
|
|
100
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
101
|
+
try {
|
|
102
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
103
|
+
return {
|
|
104
|
+
loaded: true,
|
|
105
|
+
binary: nodeRequire(join(here, `../../index.${suffix}.node`)) as T,
|
|
106
|
+
};
|
|
107
|
+
} catch (cause) {
|
|
108
|
+
return { loaded: false, suffix, cause };
|
|
109
|
+
}
|
|
110
|
+
}
|