@reproapp/node-sdk 0.0.47 → 0.0.49
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 +7 -1
- package/dist/index.js +173 -56
- package/dist/semantic-serialization.d.ts +9 -0
- package/dist/semantic-serialization.js +171 -0
- package/package.json +3 -3
- package/src/index.ts +296 -56
- package/src/semantic-serialization.ts +182 -0
- package/test/content-addressed-mongodb.testcontainers.test.js +367 -0
- package/test/content-addressed-trace-values.test.js +264 -0
- package/test/fixtures/semantic-serialization-trace-controller.js +85 -0
- package/test/fixtures/semantic-serialization-trace-server.js +19 -0
- package/test/kafka-runtime-privacy-policy.test.js +26 -2
- package/test/policy-session-completion.testcontainers.test.js +18 -1
- package/test/semantic-serialization-trace.test.js +152 -0
- package/test/semantic-serialization.test.js +229 -0
- package/test/session-storage-budget.test.js +298 -0
- package/test/trace-batch-size.test.js +33 -0
- package/test/trace-observation-snapshots.test.js +403 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectSemanticInfrastructureValue = void 0;
|
|
4
|
+
function constructorName(value) {
|
|
5
|
+
if (!value || typeof value !== 'object')
|
|
6
|
+
return '';
|
|
7
|
+
try {
|
|
8
|
+
const prototype = Object.getPrototypeOf(value);
|
|
9
|
+
const constructor = prototype
|
|
10
|
+
? Object.getOwnPropertyDescriptor(prototype, 'constructor')?.value
|
|
11
|
+
: undefined;
|
|
12
|
+
const name = constructor?.name;
|
|
13
|
+
return typeof name === 'string' ? name : '';
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function ownDataDescriptors(value) {
|
|
20
|
+
const out = {};
|
|
21
|
+
let descriptors;
|
|
22
|
+
try {
|
|
23
|
+
descriptors = Object.getOwnPropertyDescriptors(value);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(descriptor, 'value')) {
|
|
30
|
+
out[key] = descriptor;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
function method(value, key) {
|
|
36
|
+
try {
|
|
37
|
+
let current = value;
|
|
38
|
+
while (current) {
|
|
39
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
40
|
+
if (descriptor) {
|
|
41
|
+
return Object.prototype.hasOwnProperty.call(descriptor, 'value') &&
|
|
42
|
+
typeof descriptor.value === 'function';
|
|
43
|
+
}
|
|
44
|
+
current = Object.getPrototypeOf(current);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function primitiveStateValue(value) {
|
|
53
|
+
if (value === null)
|
|
54
|
+
return null;
|
|
55
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
if (typeof value === 'bigint')
|
|
59
|
+
return value.toString();
|
|
60
|
+
if (value instanceof Date)
|
|
61
|
+
return value.toISOString();
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
function semanticValue(category, className, details = {}) {
|
|
65
|
+
return {
|
|
66
|
+
matched: true,
|
|
67
|
+
value: {
|
|
68
|
+
__kind: 'repro-semantic',
|
|
69
|
+
category,
|
|
70
|
+
...(className ? { className } : {}),
|
|
71
|
+
...details,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function projectConfigurationService(value, className) {
|
|
76
|
+
if (!/(^|Api|App|Runtime|Environment)ConfigService$/i.test(className))
|
|
77
|
+
return null;
|
|
78
|
+
if (!method(value, 'get') && !method(value, 'getOrThrow'))
|
|
79
|
+
return null;
|
|
80
|
+
return semanticValue('configuration-service', className);
|
|
81
|
+
}
|
|
82
|
+
function projectLogger(value, className) {
|
|
83
|
+
if (!/(Logger|LoggerService)$/i.test(className))
|
|
84
|
+
return null;
|
|
85
|
+
const descriptors = ownDataDescriptors(value);
|
|
86
|
+
const context = primitiveStateValue(descriptors.context?.value);
|
|
87
|
+
return semanticValue('logger', className, context !== undefined ? { context } : {});
|
|
88
|
+
}
|
|
89
|
+
function projectNestInfrastructure(value, className) {
|
|
90
|
+
if (!/(ModuleRef|ModulesContainer|InstanceWrapper|NestContainer|Injector|DiscoveryService|ExecutionContextHost|ArgumentsHost|HttpAdapterHost)$/i.test(className)) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return semanticValue('nestjs-infrastructure', className);
|
|
94
|
+
}
|
|
95
|
+
function projectRedis(value, className) {
|
|
96
|
+
const looksLikeRedis = /Redis|Commander|Cluster/i.test(className) && (method(value, 'get') || method(value, 'set') || method(value, 'pipeline') || method(value, 'multi'));
|
|
97
|
+
if (!looksLikeRedis)
|
|
98
|
+
return null;
|
|
99
|
+
const descriptors = ownDataDescriptors(value);
|
|
100
|
+
const status = primitiveStateValue(descriptors.status?.value);
|
|
101
|
+
return semanticValue('redis-client', className, status !== undefined ? { status } : {});
|
|
102
|
+
}
|
|
103
|
+
function projectKafka(value, className) {
|
|
104
|
+
if (!/Kafka/i.test(className))
|
|
105
|
+
return null;
|
|
106
|
+
if (method(value, 'send') && method(value, 'connect') && method(value, 'disconnect')) {
|
|
107
|
+
return semanticValue('kafka-producer', className || 'KafkaProducer');
|
|
108
|
+
}
|
|
109
|
+
if (method(value, 'subscribe') && method(value, 'run') && method(value, 'connect')) {
|
|
110
|
+
return semanticValue('kafka-consumer', className || 'KafkaConsumer');
|
|
111
|
+
}
|
|
112
|
+
if (method(value, 'listTopics') && method(value, 'connect') && method(value, 'disconnect')) {
|
|
113
|
+
return semanticValue('kafka-admin', className || 'KafkaAdmin');
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
function projectAmqp(value, className) {
|
|
118
|
+
if (!/(Amqp|Channel|ChannelModel|ConfirmChannel)/i.test(className))
|
|
119
|
+
return null;
|
|
120
|
+
if (method(value, 'publish') && method(value, 'sendToQueue') && method(value, 'ack')) {
|
|
121
|
+
return semanticValue('amqp-channel', className || 'AmqpChannel');
|
|
122
|
+
}
|
|
123
|
+
if (method(value, 'createChannel') && method(value, 'close')) {
|
|
124
|
+
return semanticValue('amqp-connection', className || 'AmqpConnection');
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
function projectPostgres(value, className) {
|
|
129
|
+
if (/^(Pool|BoundPool)$/i.test(className) && method(value, 'query') && method(value, 'connect')) {
|
|
130
|
+
return semanticValue('postgres-pool', className);
|
|
131
|
+
}
|
|
132
|
+
if (/^(Client|PoolClient)$/i.test(className) && method(value, 'query')) {
|
|
133
|
+
return semanticValue('postgres-client', className);
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
function projectTypeOrm(value, className) {
|
|
138
|
+
if (/^DataSource$/i.test(className) && method(value, 'createQueryRunner')) {
|
|
139
|
+
return semanticValue('typeorm-infrastructure', className);
|
|
140
|
+
}
|
|
141
|
+
if (/^EntityManager$/i.test(className) && method(value, 'getRepository') && method(value, 'query')) {
|
|
142
|
+
return semanticValue('typeorm-infrastructure', className);
|
|
143
|
+
}
|
|
144
|
+
if (/^QueryRunner$/i.test(className) && method(value, 'query') && method(value, 'release')) {
|
|
145
|
+
return semanticValue('typeorm-infrastructure', className);
|
|
146
|
+
}
|
|
147
|
+
if (/^Repository$/i.test(className) && method(value, 'find') && method(value, 'save')) {
|
|
148
|
+
return semanticValue('typeorm-infrastructure', className);
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Projects known runtime machinery into stable, non-recursive descriptions.
|
|
154
|
+
* Unknown application values deliberately return null and remain fully captured.
|
|
155
|
+
*/
|
|
156
|
+
function projectSemanticInfrastructureValue(value) {
|
|
157
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
158
|
+
return null;
|
|
159
|
+
const className = constructorName(value);
|
|
160
|
+
if (!className || className === 'Object')
|
|
161
|
+
return null;
|
|
162
|
+
return (projectConfigurationService(value, className) ||
|
|
163
|
+
projectLogger(value, className) ||
|
|
164
|
+
projectNestInfrastructure(value, className) ||
|
|
165
|
+
projectRedis(value, className) ||
|
|
166
|
+
projectKafka(value, className) ||
|
|
167
|
+
projectAmqp(value, className) ||
|
|
168
|
+
projectPostgres(value, className) ||
|
|
169
|
+
projectTypeOrm(value, className));
|
|
170
|
+
}
|
|
171
|
+
exports.projectSemanticInfrastructureValue = projectSemanticInfrastructureValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reproapp/node-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"description": "Repro Nest SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"build": "tsc -p tsconfig.json",
|
|
13
13
|
"dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
|
|
14
14
|
"prepublishOnly": "npm run build",
|
|
15
|
-
"test": "npm run build && node test/trace-source-exclude.test.js && node test/unawaited.test.js && node test/integration-unawaited.js && node test/request-flush-timing.test.js && node test/request-capture-background.test.js && node test/init-auto-http-server.test.js && node test/backend-live-mode.test.js && node test/client-performance-regression.test.js && node test/request-manifest-priority.test.js && node test/runtime-no-double-invoke.test.js && node test/express-trace-http-args.test.js && node test/trace-batch-size.test.js && node test/sdk-background-priority.test.js && node test/sdk-background-timeout-isolation.test.js && node test/runtime-service-registration.test.js && node test/ingest-queue-retention.test.js && node test/ingest-high-priority-retention.test.js && node test/ingest-high-priority-fairness.test.js && node test/ingest-critical-retention.test.js && node test/ingest-critical-retry-retention.test.js && node test/ingest-batching.test.js && node test/ingest-timeout.test.js && node -r ./tracer/register test/promise-map.test.js && node test/disable-subtree.test.js && node test/circular-capture.test.js && node test/wrap-plugin-arrow-args.test.js && node test/wrap-plugin-super-call.test.js && node test/function-arg-identity.test.js && node test/privacy-service-scope.test.js && node test/privacy-policy-index.test.js && node test/policy-capture-attestation.test.js && node test/privacy-runtime-policy.test.js && node test/runtime-privacy-materialization.test.js && node test/kafka-runtime-privacy-policy.test.js && node test/amqplib-integration.test.js && node test/mongodb-integration.test.js && node test/mongodb-esm-import-hook.test.js && node test/mongodb-suppression-cleanup.test.js && node test/postgresql-integration.test.js",
|
|
16
|
-
"test:containers": "npm run build && node test/runtime-no-double-invoke.testcontainers.test.js && node test/wrap-plugin-super-call.testcontainers.test.js && node test/function-arg-identity.testcontainers.test.js && node test/mongodb-mongoose-native-suppression.testcontainers.test.js && node test/policy-session-completion.testcontainers.test.js && node test/postgresql-integrations.testcontainers.test.js"
|
|
15
|
+
"test": "npm run build && node test/semantic-serialization.test.js && node test/semantic-serialization-trace.test.js && node test/content-addressed-trace-values.test.js && node test/trace-observation-snapshots.test.js && node test/session-storage-budget.test.js && node test/trace-source-exclude.test.js && node test/unawaited.test.js && node test/integration-unawaited.js && node test/request-flush-timing.test.js && node test/request-capture-background.test.js && node test/init-auto-http-server.test.js && node test/backend-live-mode.test.js && node test/client-performance-regression.test.js && node test/request-manifest-priority.test.js && node test/runtime-no-double-invoke.test.js && node test/express-trace-http-args.test.js && node test/trace-batch-size.test.js && node test/sdk-background-priority.test.js && node test/sdk-background-timeout-isolation.test.js && node test/runtime-service-registration.test.js && node test/ingest-queue-retention.test.js && node test/ingest-high-priority-retention.test.js && node test/ingest-high-priority-fairness.test.js && node test/ingest-critical-retention.test.js && node test/ingest-critical-retry-retention.test.js && node test/ingest-batching.test.js && node test/ingest-timeout.test.js && node -r ./tracer/register test/promise-map.test.js && node test/disable-subtree.test.js && node test/circular-capture.test.js && node test/wrap-plugin-arrow-args.test.js && node test/wrap-plugin-super-call.test.js && node test/function-arg-identity.test.js && node test/privacy-service-scope.test.js && node test/privacy-policy-index.test.js && node test/policy-capture-attestation.test.js && node test/privacy-runtime-policy.test.js && node test/runtime-privacy-materialization.test.js && node test/kafka-runtime-privacy-policy.test.js && node test/amqplib-integration.test.js && node test/mongodb-integration.test.js && node test/mongodb-esm-import-hook.test.js && node test/mongodb-suppression-cleanup.test.js && node test/postgresql-integration.test.js",
|
|
16
|
+
"test:containers": "npm run build && node test/runtime-no-double-invoke.testcontainers.test.js && node test/wrap-plugin-super-call.testcontainers.test.js && node test/function-arg-identity.testcontainers.test.js && node test/mongodb-mongoose-native-suppression.testcontainers.test.js && node test/content-addressed-mongodb.testcontainers.test.js && node test/policy-session-completion.testcontainers.test.js && node test/postgresql-integrations.testcontainers.test.js"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"express": "^5.1.0",
|