@use-tusk/drift-node-sdk 0.1.15 → 0.1.17
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/README.md +7 -0
- package/dist/index.cjs +73 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +73 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,13 @@ For comprehensive guides and API reference, visit our [full documentation](https
|
|
|
31
31
|
- [Quick Start Guide](docs/quickstart.md) - Record and replay your first trace
|
|
32
32
|
- [Troubleshooting Guide](docs/troubleshooting.md) - Common issues and solutions
|
|
33
33
|
|
|
34
|
+
<div align="center">
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
</div>
|
|
40
|
+
|
|
34
41
|
## Requirements
|
|
35
42
|
|
|
36
43
|
Tusk Drift currently supports the following packages and versions:
|
package/dist/index.cjs
CHANGED
|
@@ -7864,7 +7864,10 @@ function getDecodedType(contentType) {
|
|
|
7864
7864
|
logger.debug(`Invalid Content-Type header: ${contentType}`);
|
|
7865
7865
|
return;
|
|
7866
7866
|
}
|
|
7867
|
-
|
|
7867
|
+
const mainType = contentTypeString.toLowerCase().split(";")[0].trim();
|
|
7868
|
+
const decodedType = CONTENT_TYPE_MAPPING[mainType];
|
|
7869
|
+
if (decodedType !== void 0) return decodedType;
|
|
7870
|
+
if (mainType.includes("json")) return DecodedType.JSON;
|
|
7868
7871
|
}
|
|
7869
7872
|
const ACCEPTABLE_CONTENT_TYPES = new Set([DecodedType.JSON, DecodedType.PLAIN_TEXT]);
|
|
7870
7873
|
|
|
@@ -8209,10 +8212,17 @@ var JsonSchemaHelper = class JsonSchemaHelper {
|
|
|
8209
8212
|
static decodeDataWithMerges(data, schemaMerges) {
|
|
8210
8213
|
if (!schemaMerges) return data;
|
|
8211
8214
|
const decodedData = { ...data };
|
|
8212
|
-
for (const [key, schema] of Object.entries(schemaMerges)) if (schema.encoding &&
|
|
8215
|
+
for (const [key, schema] of Object.entries(schemaMerges)) if (schema.encoding && data[key] !== void 0) try {
|
|
8213
8216
|
let decodedValue = data[key];
|
|
8214
|
-
if (
|
|
8215
|
-
|
|
8217
|
+
if (typeof decodedValue === "string") {
|
|
8218
|
+
if (schema.encoding === EncodingType.BASE64) decodedValue = Buffer.from(decodedValue, "base64").toString("utf8");
|
|
8219
|
+
if (schema.decodedType === DecodedType.JSON) decodedValue = JSON.parse(decodedValue);
|
|
8220
|
+
else if (!schema.decodedType) try {
|
|
8221
|
+
decodedValue = JSON.parse(decodedValue);
|
|
8222
|
+
} catch {
|
|
8223
|
+
logger.debug(`[JsonSchemaHelper] Failed to parse JSON for key: ${key}, no decodedType specified`);
|
|
8224
|
+
}
|
|
8225
|
+
}
|
|
8216
8226
|
decodedData[key] = decodedValue;
|
|
8217
8227
|
} catch (error) {
|
|
8218
8228
|
logger.debug(`[JsonSchemaHelper] Failed to decode ${key}:`, error);
|
|
@@ -11810,6 +11820,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11810
11820
|
const inputValue = {
|
|
11811
11821
|
text: queryConfig.text,
|
|
11812
11822
|
values: queryConfig.values || [],
|
|
11823
|
+
rowMode: queryConfig.rowMode,
|
|
11813
11824
|
clientType
|
|
11814
11825
|
};
|
|
11815
11826
|
if (self.mode === TuskDriftMode.REPLAY) {
|
|
@@ -11924,6 +11935,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11924
11935
|
if (typeof firstArg === "object" && firstArg.text) return {
|
|
11925
11936
|
text: firstArg.text,
|
|
11926
11937
|
values: firstArg.values,
|
|
11938
|
+
rowMode: firstArg.rowMode,
|
|
11927
11939
|
callback: firstArg.callback || (typeof args[1] === "function" ? args[1] : void 0)
|
|
11928
11940
|
};
|
|
11929
11941
|
return null;
|
|
@@ -12024,7 +12036,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12024
12036
|
logger.warn(`[PgInstrumentation] No mock data found for PG query: ${queryText}`);
|
|
12025
12037
|
throw new Error(`[PgInstrumentation] No mock data found for PG query: ${queryText}`);
|
|
12026
12038
|
}
|
|
12027
|
-
const processedResult = this.convertPostgresTypes(mockData.result);
|
|
12039
|
+
const processedResult = this.convertPostgresTypes(mockData.result, inputValue.rowMode);
|
|
12028
12040
|
if (queryConfig.callback) {
|
|
12029
12041
|
process.nextTick(() => {
|
|
12030
12042
|
queryConfig.callback(null, processedResult);
|
|
@@ -12033,35 +12045,56 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12033
12045
|
} else return Promise.resolve(processedResult);
|
|
12034
12046
|
}
|
|
12035
12047
|
/**
|
|
12048
|
+
* Convert a single value based on its PostgreSQL data type.
|
|
12049
|
+
*
|
|
12050
|
+
* Reference for data type IDs: https://jdbc.postgresql.org/documentation/publicapi/constant-values.html
|
|
12051
|
+
*/
|
|
12052
|
+
convertPostgresValue(value, dataTypeID) {
|
|
12053
|
+
if (value === null || value === void 0) return value;
|
|
12054
|
+
switch (dataTypeID) {
|
|
12055
|
+
case 1184:
|
|
12056
|
+
case 1114:
|
|
12057
|
+
case 1082:
|
|
12058
|
+
if (typeof value === "string") return new Date(value);
|
|
12059
|
+
break;
|
|
12060
|
+
case 1083:
|
|
12061
|
+
case 1266: break;
|
|
12062
|
+
default: break;
|
|
12063
|
+
}
|
|
12064
|
+
return value;
|
|
12065
|
+
}
|
|
12066
|
+
/**
|
|
12036
12067
|
* Convert PostgreSQL string values back to appropriate JavaScript types
|
|
12037
12068
|
* based on field metadata from the recorded response.
|
|
12038
12069
|
*
|
|
12039
12070
|
* Reference for data type IDs: https://jdbc.postgresql.org/documentation/publicapi/constant-values.html
|
|
12040
12071
|
*/
|
|
12041
|
-
convertPostgresTypes(result) {
|
|
12072
|
+
convertPostgresTypes(result, rowMode) {
|
|
12042
12073
|
if (!result || !result.fields || !result.rows) return result;
|
|
12074
|
+
if (rowMode === "array") {
|
|
12075
|
+
const convertedRows$1 = result.rows.map((row) => {
|
|
12076
|
+
if (!Array.isArray(row)) return row;
|
|
12077
|
+
return row.map((value, index) => {
|
|
12078
|
+
const field = result.fields[index];
|
|
12079
|
+
if (!field) return value;
|
|
12080
|
+
return this.convertPostgresValue(value, field.dataTypeID);
|
|
12081
|
+
});
|
|
12082
|
+
});
|
|
12083
|
+
return {
|
|
12084
|
+
...result,
|
|
12085
|
+
rows: convertedRows$1
|
|
12086
|
+
};
|
|
12087
|
+
}
|
|
12043
12088
|
const fieldTypeMap = {};
|
|
12044
12089
|
result.fields.forEach((field) => {
|
|
12045
12090
|
fieldTypeMap[field.name] = field.dataTypeID;
|
|
12046
12091
|
});
|
|
12047
|
-
const convertedRows = result.rows.map((row
|
|
12092
|
+
const convertedRows = result.rows.map((row) => {
|
|
12048
12093
|
const convertedRow = { ...row };
|
|
12049
12094
|
Object.keys(row).forEach((fieldName) => {
|
|
12050
12095
|
const dataTypeID = fieldTypeMap[fieldName];
|
|
12051
12096
|
const value = row[fieldName];
|
|
12052
|
-
|
|
12053
|
-
switch (dataTypeID) {
|
|
12054
|
-
case 1184:
|
|
12055
|
-
case 1114:
|
|
12056
|
-
if (typeof value === "string") convertedRow[fieldName] = new Date(value);
|
|
12057
|
-
break;
|
|
12058
|
-
case 1082:
|
|
12059
|
-
if (typeof value === "string") convertedRow[fieldName] = new Date(value);
|
|
12060
|
-
break;
|
|
12061
|
-
case 1083:
|
|
12062
|
-
case 1266: break;
|
|
12063
|
-
default: break;
|
|
12064
|
-
}
|
|
12097
|
+
convertedRow[fieldName] = this.convertPostgresValue(value, dataTypeID);
|
|
12065
12098
|
});
|
|
12066
12099
|
return convertedRow;
|
|
12067
12100
|
});
|
|
@@ -13289,6 +13322,12 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
13289
13322
|
logger.debug(`[MysqlInstrumentation] Wrapped Connection.prototype.resume`);
|
|
13290
13323
|
}
|
|
13291
13324
|
}
|
|
13325
|
+
if (ConnectionClass.prototype && ConnectionClass.prototype.destroy) {
|
|
13326
|
+
if (!isWrapped$1(ConnectionClass.prototype.destroy)) {
|
|
13327
|
+
this._wrap(ConnectionClass.prototype, "destroy", this._getDestroyPatchFn());
|
|
13328
|
+
logger.debug(`[MysqlInstrumentation] Wrapped Connection.prototype.destroy`);
|
|
13329
|
+
}
|
|
13330
|
+
}
|
|
13292
13331
|
this.markModuleAsPatched(ConnectionClass);
|
|
13293
13332
|
logger.debug(`[MysqlInstrumentation] Connection class patching complete`);
|
|
13294
13333
|
return ConnectionClass;
|
|
@@ -13703,6 +13742,19 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
13703
13742
|
};
|
|
13704
13743
|
}
|
|
13705
13744
|
/**
|
|
13745
|
+
* Get wrapper function for destroy method
|
|
13746
|
+
*/
|
|
13747
|
+
_getDestroyPatchFn() {
|
|
13748
|
+
const self = this;
|
|
13749
|
+
return (originalDestroy) => {
|
|
13750
|
+
return function destroy() {
|
|
13751
|
+
if (self.mode === TuskDriftMode.REPLAY) return;
|
|
13752
|
+
else if (self.mode === TuskDriftMode.RECORD) return originalDestroy.apply(this, arguments);
|
|
13753
|
+
else return originalDestroy.apply(this, arguments);
|
|
13754
|
+
};
|
|
13755
|
+
};
|
|
13756
|
+
}
|
|
13757
|
+
/**
|
|
13706
13758
|
* Get wrapper function for Pool.end method
|
|
13707
13759
|
*/
|
|
13708
13760
|
_getPoolEndPatchFn() {
|
|
@@ -32015,7 +32067,7 @@ var require_src = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/sdk-
|
|
|
32015
32067
|
//#endregion
|
|
32016
32068
|
//#region package.json
|
|
32017
32069
|
var import_src$1 = /* @__PURE__ */ __toESM(require_src(), 1);
|
|
32018
|
-
var version = "0.1.
|
|
32070
|
+
var version = "0.1.17";
|
|
32019
32071
|
|
|
32020
32072
|
//#endregion
|
|
32021
32073
|
//#region src/version.ts
|