@use-tusk/drift-node-sdk 0.1.25 → 0.1.26

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.js CHANGED
@@ -6203,7 +6203,7 @@ var JsonSchema$Type = class extends import_commonjs$7.MessageType {
6203
6203
  const JsonSchema = new JsonSchema$Type();
6204
6204
 
6205
6205
  //#endregion
6206
- //#region node_modules/@use-tusk/drift-schemas/dist/span-CsBrzhI_.js
6206
+ //#region node_modules/@use-tusk/drift-schemas/dist/span-CXrr1reB.js
6207
6207
  var import_commonjs$6 = /* @__PURE__ */ __toESM(require_commonjs$2(), 1);
6208
6208
  /**
6209
6209
  * Package type classification enum
@@ -6350,6 +6350,62 @@ let StatusCode = /* @__PURE__ */ function(StatusCode$1) {
6350
6350
  StatusCode$1[StatusCode$1["ERROR"] = 2] = "ERROR";
6351
6351
  return StatusCode$1;
6352
6352
  }({});
6353
+ /**
6354
+ * Match scope - where the match was found
6355
+ *
6356
+ * @generated from protobuf enum tusk.drift.core.v1.MatchScope
6357
+ */
6358
+ let MatchScope = /* @__PURE__ */ function(MatchScope$1) {
6359
+ /**
6360
+ * @generated from protobuf enum value: MATCH_SCOPE_UNSPECIFIED = 0;
6361
+ */
6362
+ MatchScope$1[MatchScope$1["UNSPECIFIED"] = 0] = "UNSPECIFIED";
6363
+ /**
6364
+ * @generated from protobuf enum value: MATCH_SCOPE_TRACE = 1;
6365
+ */
6366
+ MatchScope$1[MatchScope$1["TRACE"] = 1] = "TRACE";
6367
+ /**
6368
+ * @generated from protobuf enum value: MATCH_SCOPE_GLOBAL = 2;
6369
+ */
6370
+ MatchScope$1[MatchScope$1["GLOBAL"] = 2] = "GLOBAL";
6371
+ return MatchScope$1;
6372
+ }({});
6373
+ /**
6374
+ * Match type - how the match was found
6375
+ *
6376
+ * @generated from protobuf enum tusk.drift.core.v1.MatchType
6377
+ */
6378
+ let MatchType = /* @__PURE__ */ function(MatchType$1) {
6379
+ /**
6380
+ * @generated from protobuf enum value: MATCH_TYPE_UNSPECIFIED = 0;
6381
+ */
6382
+ MatchType$1[MatchType$1["UNSPECIFIED"] = 0] = "UNSPECIFIED";
6383
+ /**
6384
+ * @generated from protobuf enum value: MATCH_TYPE_INPUT_VALUE_HASH = 1;
6385
+ */
6386
+ MatchType$1[MatchType$1["INPUT_VALUE_HASH"] = 1] = "INPUT_VALUE_HASH";
6387
+ /**
6388
+ * @generated from protobuf enum value: MATCH_TYPE_INPUT_VALUE_HASH_REDUCED_SCHEMA = 2;
6389
+ */
6390
+ MatchType$1[MatchType$1["INPUT_VALUE_HASH_REDUCED_SCHEMA"] = 2] = "INPUT_VALUE_HASH_REDUCED_SCHEMA";
6391
+ /**
6392
+ * @generated from protobuf enum value: MATCH_TYPE_INPUT_SCHEMA_HASH = 3;
6393
+ */
6394
+ MatchType$1[MatchType$1["INPUT_SCHEMA_HASH"] = 3] = "INPUT_SCHEMA_HASH";
6395
+ /**
6396
+ * @generated from protobuf enum value: MATCH_TYPE_INPUT_SCHEMA_HASH_REDUCED_SCHEMA = 4;
6397
+ */
6398
+ MatchType$1[MatchType$1["INPUT_SCHEMA_HASH_REDUCED_SCHEMA"] = 4] = "INPUT_SCHEMA_HASH_REDUCED_SCHEMA";
6399
+ /**
6400
+ * @generated from protobuf enum value: MATCH_TYPE_FUZZY = 5;
6401
+ */
6402
+ MatchType$1[MatchType$1["FUZZY"] = 5] = "FUZZY";
6403
+ /**
6404
+ * @generated from protobuf enum value: MATCH_TYPE_FALLBACK = 6;
6405
+ */
6406
+ MatchType$1[MatchType$1["FALLBACK"] = 6] = "FALLBACK";
6407
+ return MatchType$1;
6408
+ }({});
6353
6409
  var Span$Type = class extends import_commonjs$6.MessageType {
6354
6410
  constructor() {
6355
6411
  super("tusk.drift.core.v1.Span", [
@@ -6996,6 +7052,157 @@ var Trace$Type = class extends import_commonjs$6.MessageType {
6996
7052
  * @generated MessageType for protobuf message tusk.drift.core.v1.Trace
6997
7053
  */
6998
7054
  const Trace = new Trace$Type();
7055
+ var SimilarityCandidate$Type = class extends import_commonjs$6.MessageType {
7056
+ constructor() {
7057
+ super("tusk.drift.core.v1.SimilarityCandidate", [{
7058
+ no: 1,
7059
+ name: "span_id",
7060
+ kind: "scalar",
7061
+ T: 9
7062
+ }, {
7063
+ no: 2,
7064
+ name: "score",
7065
+ kind: "scalar",
7066
+ T: 2
7067
+ }]);
7068
+ }
7069
+ create(value) {
7070
+ const message = globalThis.Object.create(this.messagePrototype);
7071
+ message.spanId = "";
7072
+ message.score = 0;
7073
+ if (value !== void 0) (0, import_commonjs$6.reflectionMergePartial)(this, message, value);
7074
+ return message;
7075
+ }
7076
+ internalBinaryRead(reader, length, options, target) {
7077
+ let message = target ?? this.create(), end = reader.pos + length;
7078
+ while (reader.pos < end) {
7079
+ let [fieldNo, wireType] = reader.tag();
7080
+ switch (fieldNo) {
7081
+ case 1:
7082
+ message.spanId = reader.string();
7083
+ break;
7084
+ case 2:
7085
+ message.score = reader.float();
7086
+ break;
7087
+ default:
7088
+ let u = options.readUnknownField;
7089
+ if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7090
+ let d = reader.skip(wireType);
7091
+ if (u !== false) (u === true ? import_commonjs$6.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7092
+ }
7093
+ }
7094
+ return message;
7095
+ }
7096
+ internalBinaryWrite(message, writer, options) {
7097
+ if (message.spanId !== "") writer.tag(1, import_commonjs$6.WireType.LengthDelimited).string(message.spanId);
7098
+ if (message.score !== 0) writer.tag(2, import_commonjs$6.WireType.Bit32).float(message.score);
7099
+ let u = options.writeUnknownFields;
7100
+ if (u !== false) (u == true ? import_commonjs$6.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7101
+ return writer;
7102
+ }
7103
+ };
7104
+ /**
7105
+ * @generated MessageType for protobuf message tusk.drift.core.v1.SimilarityCandidate
7106
+ */
7107
+ const SimilarityCandidate = new SimilarityCandidate$Type();
7108
+ var MatchLevel$Type = class extends import_commonjs$6.MessageType {
7109
+ constructor() {
7110
+ super("tusk.drift.core.v1.MatchLevel", [
7111
+ {
7112
+ no: 1,
7113
+ name: "match_type",
7114
+ kind: "enum",
7115
+ T: () => [
7116
+ "tusk.drift.core.v1.MatchType",
7117
+ MatchType,
7118
+ "MATCH_TYPE_"
7119
+ ]
7120
+ },
7121
+ {
7122
+ no: 2,
7123
+ name: "match_scope",
7124
+ kind: "enum",
7125
+ T: () => [
7126
+ "tusk.drift.core.v1.MatchScope",
7127
+ MatchScope,
7128
+ "MATCH_SCOPE_"
7129
+ ]
7130
+ },
7131
+ {
7132
+ no: 3,
7133
+ name: "match_description",
7134
+ kind: "scalar",
7135
+ T: 9
7136
+ },
7137
+ {
7138
+ no: 4,
7139
+ name: "similarity_score",
7140
+ kind: "scalar",
7141
+ opt: true,
7142
+ T: 2
7143
+ },
7144
+ {
7145
+ no: 5,
7146
+ name: "top_candidates",
7147
+ kind: "message",
7148
+ repeat: 2,
7149
+ T: () => SimilarityCandidate
7150
+ }
7151
+ ]);
7152
+ }
7153
+ create(value) {
7154
+ const message = globalThis.Object.create(this.messagePrototype);
7155
+ message.matchType = 0;
7156
+ message.matchScope = 0;
7157
+ message.matchDescription = "";
7158
+ message.topCandidates = [];
7159
+ if (value !== void 0) (0, import_commonjs$6.reflectionMergePartial)(this, message, value);
7160
+ return message;
7161
+ }
7162
+ internalBinaryRead(reader, length, options, target) {
7163
+ let message = target ?? this.create(), end = reader.pos + length;
7164
+ while (reader.pos < end) {
7165
+ let [fieldNo, wireType] = reader.tag();
7166
+ switch (fieldNo) {
7167
+ case 1:
7168
+ message.matchType = reader.int32();
7169
+ break;
7170
+ case 2:
7171
+ message.matchScope = reader.int32();
7172
+ break;
7173
+ case 3:
7174
+ message.matchDescription = reader.string();
7175
+ break;
7176
+ case 4:
7177
+ message.similarityScore = reader.float();
7178
+ break;
7179
+ case 5:
7180
+ message.topCandidates.push(SimilarityCandidate.internalBinaryRead(reader, reader.uint32(), options));
7181
+ break;
7182
+ default:
7183
+ let u = options.readUnknownField;
7184
+ if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7185
+ let d = reader.skip(wireType);
7186
+ if (u !== false) (u === true ? import_commonjs$6.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7187
+ }
7188
+ }
7189
+ return message;
7190
+ }
7191
+ internalBinaryWrite(message, writer, options) {
7192
+ if (message.matchType !== 0) writer.tag(1, import_commonjs$6.WireType.Varint).int32(message.matchType);
7193
+ if (message.matchScope !== 0) writer.tag(2, import_commonjs$6.WireType.Varint).int32(message.matchScope);
7194
+ if (message.matchDescription !== "") writer.tag(3, import_commonjs$6.WireType.LengthDelimited).string(message.matchDescription);
7195
+ if (message.similarityScore !== void 0) writer.tag(4, import_commonjs$6.WireType.Bit32).float(message.similarityScore);
7196
+ for (let i = 0; i < message.topCandidates.length; i++) SimilarityCandidate.internalBinaryWrite(message.topCandidates[i], writer.tag(5, import_commonjs$6.WireType.LengthDelimited).fork(), options).join();
7197
+ let u = options.writeUnknownFields;
7198
+ if (u !== false) (u == true ? import_commonjs$6.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7199
+ return writer;
7200
+ }
7201
+ };
7202
+ /**
7203
+ * @generated MessageType for protobuf message tusk.drift.core.v1.MatchLevel
7204
+ */
7205
+ const MatchLevel = new MatchLevel$Type();
6999
7206
 
7000
7207
  //#endregion
7001
7208
  //#region src/core/utils/protobufUtils.ts
@@ -7057,6 +7264,50 @@ function valueToProtobufValue(value) {
7057
7264
  stringValue: String(value)
7058
7265
  } });
7059
7266
  }
7267
+ /**
7268
+ * Human-readable labels for MatchType enum values
7269
+ */
7270
+ const MATCH_TYPE_LABELS = {
7271
+ [MatchType.UNSPECIFIED]: "UNSPECIFIED",
7272
+ [MatchType.INPUT_VALUE_HASH]: "INPUT_VALUE_HASH",
7273
+ [MatchType.INPUT_VALUE_HASH_REDUCED_SCHEMA]: "INPUT_VALUE_HASH_REDUCED_SCHEMA",
7274
+ [MatchType.INPUT_SCHEMA_HASH]: "INPUT_SCHEMA_HASH",
7275
+ [MatchType.INPUT_SCHEMA_HASH_REDUCED_SCHEMA]: "INPUT_SCHEMA_HASH_REDUCED_SCHEMA",
7276
+ [MatchType.FUZZY]: "FUZZY",
7277
+ [MatchType.FALLBACK]: "FALLBACK"
7278
+ };
7279
+ /**
7280
+ * Human-readable labels for MatchScope enum values
7281
+ */
7282
+ const MATCH_SCOPE_LABELS = {
7283
+ [MatchScope.UNSPECIFIED]: "UNSPECIFIED",
7284
+ [MatchScope.TRACE]: "TRACE",
7285
+ [MatchScope.GLOBAL]: "GLOBAL"
7286
+ };
7287
+ /**
7288
+ * Converts a MatchType enum to a human-readable label
7289
+ */
7290
+ function getMatchTypeLabel(matchType) {
7291
+ return MATCH_TYPE_LABELS[matchType] ?? `UNKNOWN(${matchType})`;
7292
+ }
7293
+ /**
7294
+ * Converts a MatchScope enum to a human-readable label
7295
+ */
7296
+ function getMatchScopeLabel(matchScope) {
7297
+ return MATCH_SCOPE_LABELS[matchScope] ?? `UNKNOWN(${matchScope})`;
7298
+ }
7299
+ /**
7300
+ * Formats a matchLevel object as a concise, readable string for logging
7301
+ */
7302
+ function formatMatchLevelForLog(matchLevel) {
7303
+ if (!matchLevel) return "No match level info";
7304
+ const matchType = matchLevel.matchType ?? MatchType.UNSPECIFIED;
7305
+ const matchScope = matchLevel.matchScope ?? MatchScope.UNSPECIFIED;
7306
+ let result = `[${getMatchTypeLabel(matchType)}] scope=${getMatchScopeLabel(matchScope)}`;
7307
+ if (matchLevel.matchDescription) result += ` - "${matchLevel.matchDescription}"`;
7308
+ if (matchLevel.similarityScore !== void 0) result += ` (score: ${matchLevel.similarityScore})`;
7309
+ return result;
7310
+ }
7060
7311
 
7061
7312
  //#endregion
7062
7313
  //#region src/core/utils/OriginalGlobalUtils.ts
@@ -8324,7 +8575,7 @@ async function findMockResponseAsync({ mockRequestData, tuskDrift, inputValueSch
8324
8575
  return null;
8325
8576
  }
8326
8577
  const responseBody = mockResponse.response?.response?.body;
8327
- logger.debug(`Found ${outboundSpan.traceId} mock response:`, responseBody, { timestamp: mockResponse.response?.timestamp });
8578
+ logger.debug(`Found ${outboundSpan.traceId} mock response:`);
8328
8579
  if (mockResponse.response?.timestamp) DateTracker.updateLatestTimestamp(replayTraceId || "", mockResponse.response.timestamp);
8329
8580
  return { result: responseBody };
8330
8581
  } catch (error) {
@@ -8346,7 +8597,7 @@ function findMockResponseSync({ mockRequestData, tuskDrift, inputValueSchemaMerg
8346
8597
  return null;
8347
8598
  }
8348
8599
  const responseBody = mockResponse.response?.response?.body;
8349
- logger.debug(`Found ${outboundSpan.traceId} mock response and timestamp:`, responseBody, { timestamp: mockResponse.response?.timestamp });
8600
+ logger.debug(`Found ${outboundSpan.traceId} mock response:`);
8350
8601
  if (mockResponse.response?.timestamp) DateTracker.updateLatestTimestamp(replayTraceId || "", mockResponse.response.timestamp);
8351
8602
  return { result: responseBody };
8352
8603
  } catch (error) {
@@ -9970,7 +10221,7 @@ var require_commonjs$1 = /* @__PURE__ */ __commonJS({ "node_modules/@protobuf-ts
9970
10221
  }) });
9971
10222
 
9972
10223
  //#endregion
9973
- //#region node_modules/@use-tusk/drift-schemas/dist/span_export_service-CmkFvTqD.js
10224
+ //#region node_modules/@use-tusk/drift-schemas/dist/span_export_service-RmRqNxn1.js
9974
10225
  var import_commonjs$4 = /* @__PURE__ */ __toESM(require_commonjs$1(), 1);
9975
10226
  var import_commonjs$5 = /* @__PURE__ */ __toESM(require_commonjs$2(), 1);
9976
10227
  var ExportSpansRequest$Type = class extends import_commonjs$5.MessageType {
@@ -33466,7 +33717,7 @@ var require_src = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/sdk-
33466
33717
  //#endregion
33467
33718
  //#region package.json
33468
33719
  var import_src$1 = /* @__PURE__ */ __toESM(require_src(), 1);
33469
- var version = "0.1.25";
33720
+ var version = "0.1.26";
33470
33721
 
33471
33722
  //#endregion
33472
33723
  //#region src/version.ts
@@ -33474,7 +33725,7 @@ const SDK_VERSION = version;
33474
33725
  const MIN_CLI_VERSION = "0.1.0";
33475
33726
 
33476
33727
  //#endregion
33477
- //#region node_modules/@use-tusk/drift-schemas/dist/communication-BY2KZhrg.js
33728
+ //#region node_modules/@use-tusk/drift-schemas/dist/communication-CVqe2frO.js
33478
33729
  var import_commonjs = /* @__PURE__ */ __toESM(require_commonjs$1(), 1);
33479
33730
  var import_commonjs$1 = /* @__PURE__ */ __toESM(require_commonjs$2(), 1);
33480
33731
  /**
@@ -33816,6 +34067,12 @@ var GetMockResponse$Type = class extends import_commonjs$1.MessageType {
33816
34067
  name: "matched_at",
33817
34068
  kind: "message",
33818
34069
  T: () => Timestamp
34070
+ },
34071
+ {
34072
+ no: 9,
34073
+ name: "match_level",
34074
+ kind: "message",
34075
+ T: () => MatchLevel
33819
34076
  }
33820
34077
  ]);
33821
34078
  }
@@ -33858,6 +34115,9 @@ var GetMockResponse$Type = class extends import_commonjs$1.MessageType {
33858
34115
  case 8:
33859
34116
  message.matchedAt = Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.matchedAt);
33860
34117
  break;
34118
+ case 9:
34119
+ message.matchLevel = MatchLevel.internalBinaryRead(reader, reader.uint32(), options, message.matchLevel);
34120
+ break;
33861
34121
  default:
33862
34122
  let u = options.readUnknownField;
33863
34123
  if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
@@ -33876,6 +34136,7 @@ var GetMockResponse$Type = class extends import_commonjs$1.MessageType {
33876
34136
  if (message.errorCode !== "") writer.tag(6, import_commonjs$1.WireType.LengthDelimited).string(message.errorCode);
33877
34137
  if (message.matchedSpanId !== "") writer.tag(7, import_commonjs$1.WireType.LengthDelimited).string(message.matchedSpanId);
33878
34138
  if (message.matchedAt) Timestamp.internalBinaryWrite(message.matchedAt, writer.tag(8, import_commonjs$1.WireType.LengthDelimited).fork(), options).join();
34139
+ if (message.matchLevel) MatchLevel.internalBinaryWrite(message.matchLevel, writer.tag(9, import_commonjs$1.WireType.LengthDelimited).fork(), options).join();
33879
34140
  let u = options.writeUnknownFields;
33880
34141
  if (u !== false) (u == true ? import_commonjs$1.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
33881
34142
  return writer;
@@ -34941,7 +35202,7 @@ var ProtobufCommunicator = class ProtobufCommunicator {
34941
35202
  if (struct.fields && struct.fields["response"]) {
34942
35203
  const responseValue = Value.toJson(struct.fields["response"]);
34943
35204
  if (responseValue) {
34944
- logger.debug("[ProtobufCommunicator] Extracted response data:", JSON.stringify(responseValue, null, 2));
35205
+ logger.debug("[ProtobufCommunicator] Extracted response data:", JSON.stringify(responseValue, null, 2), "\nMatch level:", formatMatchLevelForLog(mockResponse.matchLevel));
34945
35206
  return responseValue;
34946
35207
  }
34947
35208
  }
@@ -35412,7 +35673,7 @@ var TuskDriftCore = class TuskDriftCore {
35412
35673
  logger.error("Failed to send inbound replay span:", e);
35413
35674
  }
35414
35675
  }
35415
- createMockRequestCore(mockRequest) {
35676
+ createMockRequestCore() {
35416
35677
  if (!this.communicator || this.mode !== TuskDriftMode.REPLAY) {
35417
35678
  logger.error("Cannot request mock: not in replay mode or no CLI connection", this.mode, this.communicator);
35418
35679
  return {
@@ -35427,7 +35688,7 @@ var TuskDriftCore = class TuskDriftCore {
35427
35688
  logger.debug("Waiting for CLI connection to be established");
35428
35689
  await this.cliConnectionPromise;
35429
35690
  }
35430
- const mockRequestCore = this.createMockRequestCore(mockRequest);
35691
+ const mockRequestCore = this.createMockRequestCore();
35431
35692
  if (mockRequestCore) return mockRequestCore;
35432
35693
  return this.requestMockFromCLIAsync(mockRequest);
35433
35694
  }
@@ -35441,12 +35702,10 @@ var TuskDriftCore = class TuskDriftCore {
35441
35702
  }
35442
35703
  try {
35443
35704
  logger.debug("Sending protobuf request to CLI (async)", JSON.stringify(mockRequest, null, 2));
35444
- const response = await this.communicator.requestMockAsync({
35705
+ return await this.communicator.requestMockAsync({
35445
35706
  testId: mockRequest.testId,
35446
35707
  outboundSpan: mockRequest.outboundSpan
35447
35708
  });
35448
- logger.debug("Received protobuf response from CLI", JSON.stringify(response, null, 2));
35449
- return response;
35450
35709
  } catch (error) {
35451
35710
  logger.error("Error sending protobuf request to CLI:", error);
35452
35711
  return {
@@ -35460,7 +35719,7 @@ var TuskDriftCore = class TuskDriftCore {
35460
35719
  logger.error("Requesting sync mock but CLI is not ready yet");
35461
35720
  throw new Error("Requesting sync mock but CLI is not ready yet");
35462
35721
  }
35463
- const mockRequestCore = this.createMockRequestCore(mockRequest);
35722
+ const mockRequestCore = this.createMockRequestCore();
35464
35723
  if (mockRequestCore) return mockRequestCore;
35465
35724
  return this.requestMockFromCLISync(mockRequest);
35466
35725
  }
@@ -35474,12 +35733,10 @@ var TuskDriftCore = class TuskDriftCore {
35474
35733
  }
35475
35734
  try {
35476
35735
  logger.debug("Sending protobuf request to CLI (sync)", mockRequest);
35477
- const response = this.communicator.requestMockSync({
35736
+ return this.communicator.requestMockSync({
35478
35737
  testId: mockRequest.testId,
35479
35738
  outboundSpan: mockRequest.outboundSpan
35480
35739
  });
35481
- logger.debug("Received protobuf response from CLI", response);
35482
- return response;
35483
35740
  } catch (error) {
35484
35741
  logger.error("Error sending protobuf request to CLI:", error);
35485
35742
  return {