@reqray/core 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ruslan Kryklyvyi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,59 @@
1
- # Temporary Holding Version
1
+ # @reqray/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The core of Reqray: the request context, the span buffer, masking, sampling and
4
+ the detectors. No third-party runtime dependencies.
5
+
6
+ Part of [Reqray](https://github.com/reqray/reqray) — a dev panel and request inspector for Node.js. It
7
+ instruments HTTP, SQL, outgoing calls and cache on its own, shows every
8
+ request as a waterfall, and finds N+1 down to the file and the line.
9
+
10
+ ## You probably want an adapter
11
+
12
+ To use Reqray in an application, install
13
+ [`@reqray/register`](https://www.npmjs.com/package/@reqray/register) and one of
14
+ [`@reqray/fastify`](https://www.npmjs.com/package/@reqray/fastify),
15
+ [`@reqray/express`](https://www.npmjs.com/package/@reqray/express),
16
+ [`@reqray/nestjs`](https://www.npmjs.com/package/@reqray/nestjs). They depend on
17
+ this package; you do not need to install it yourself.
18
+
19
+ This package is for writing an adapter for another framework or an
20
+ instrumentation for another driver.
21
+
22
+ ## What is in it
23
+
24
+ - **Request context.** `AsyncLocalStorage` holds a `RequestScope` for the
25
+ request being handled; `current()` returns it, or `undefined` outside a
26
+ request — in which case an instrumentation simply does nothing.
27
+ - **Recording.** `record(scope, span)` adds a span. Masking of sensitive
28
+ fields happens here, before anything reaches the buffer.
29
+ - **`createReqray(options)`** — what an adapter calls once: it resolves the
30
+ options, owns the transports and exposes the panel's request handler.
31
+ - **The instrumentation kit**: `patchMethod` / `unpatchMethod`, `settle` /
32
+ `settleCallback` for the promise-or-callback split, `guarded` for the
33
+ try/catch that disables one instrumentation instead of reaching the
34
+ application, `fingerprintSql` for normalizing statements.
35
+ - **Detectors**: N+1, sequential HTTP, duplicate calls and cache reads, pool
36
+ wait, a transaction held across a call, heavy responses, slow code, time
37
+ budgets. They run after the response has been sent.
38
+
39
+ ```js
40
+ import { current, record, fingerprintSql } from '@reqray/core';
41
+
42
+ const scope = current();
43
+ if (scope) {
44
+ record(scope, { kind: 'db', sql, fingerprint: fingerprintSql(sql), duration });
45
+ }
46
+ ```
47
+
48
+ Two rules an instrumentation has to keep: never change the behaviour of what
49
+ it wraps, and never let its own error reach the application.
50
+
51
+ ## More
52
+
53
+ Everything else — the detectors, security defaults, measured overhead and a
54
+ demo that runs with one command — is in the
55
+ [main README](https://github.com/reqray/reqray#readme).
56
+
57
+ ## License
58
+
59
+ [MIT](https://github.com/reqray/reqray/blob/main/LICENSE)
@@ -0,0 +1,22 @@
1
+ import {
2
+ globalBox
3
+ } from "./chunk-EIQ7LFT6.js";
4
+
5
+ // src/presence.ts
6
+ var adapterActive = globalBox("presence.adapterActive", false);
7
+ function markAdapterActive() {
8
+ adapterActive().value = true;
9
+ }
10
+ function isAdapterActive() {
11
+ return adapterActive().value;
12
+ }
13
+ function resetAdapterActive() {
14
+ adapterActive().value = false;
15
+ }
16
+
17
+ export {
18
+ markAdapterActive,
19
+ isAdapterActive,
20
+ resetAdapterActive
21
+ };
22
+ //# sourceMappingURL=chunk-B5PLSUI7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/presence.ts"],"sourcesContent":["/**\n * Adapter presence flag.\n *\n * Framework adapters announce themselves so the standalone mode in\n * `@reqray/register` can stand down: it exists only for applications with no\n * adapter, and recording the same request twice would be worse than either\n * record alone.\n */\n\nimport { globalBox } from './state.js';\n\n/**\n * A framework adapter has been initialized.\n *\n * The standalone mode in `@reqray/register` checks this to stand down: an\n * adapter records the same requests with full fidelity.\n */\nconst adapterActive = globalBox('presence.adapterActive', false);\n\n/** Called by every framework adapter at initialization. */\nexport function markAdapterActive(): void {\n adapterActive().value = true;\n}\n\n/** Whether any framework adapter has been initialized in this process. */\nexport function isAdapterActive(): boolean {\n return adapterActive().value;\n}\n\n/** Resets the flag. Needed by tests. */\nexport function resetAdapterActive(): void {\n adapterActive().value = false;\n}\n"],"mappings":";;;;;AAiBA,IAAM,gBAAgB,UAAU,0BAA0B,KAAK;AAGxD,SAAS,oBAA0B;AACxC,gBAAc,EAAE,QAAQ;AAC1B;AAGO,SAAS,kBAA2B;AACzC,SAAO,cAAc,EAAE;AACzB;AAGO,SAAS,qBAA2B;AACzC,gBAAc,EAAE,QAAQ;AAC1B;","names":[]}