@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.cjs CHANGED
@@ -6214,7 +6214,7 @@ var JsonSchema$Type = class extends import_commonjs$7.MessageType {
6214
6214
  const JsonSchema = new JsonSchema$Type();
6215
6215
 
6216
6216
  //#endregion
6217
- //#region node_modules/@use-tusk/drift-schemas/dist/span-CsBrzhI_.js
6217
+ //#region node_modules/@use-tusk/drift-schemas/dist/span-CXrr1reB.js
6218
6218
  var import_commonjs$6 = /* @__PURE__ */ __toESM(require_commonjs$2(), 1);
6219
6219
  /**
6220
6220
  * Package type classification enum
@@ -6361,6 +6361,62 @@ let StatusCode = /* @__PURE__ */ function(StatusCode$1) {
6361
6361
  StatusCode$1[StatusCode$1["ERROR"] = 2] = "ERROR";
6362
6362
  return StatusCode$1;
6363
6363
  }({});
6364
+ /**
6365
+ * Match scope - where the match was found
6366
+ *
6367
+ * @generated from protobuf enum tusk.drift.core.v1.MatchScope
6368
+ */
6369
+ let MatchScope = /* @__PURE__ */ function(MatchScope$1) {
6370
+ /**
6371
+ * @generated from protobuf enum value: MATCH_SCOPE_UNSPECIFIED = 0;
6372
+ */
6373
+ MatchScope$1[MatchScope$1["UNSPECIFIED"] = 0] = "UNSPECIFIED";
6374
+ /**
6375
+ * @generated from protobuf enum value: MATCH_SCOPE_TRACE = 1;
6376
+ */
6377
+ MatchScope$1[MatchScope$1["TRACE"] = 1] = "TRACE";
6378
+ /**
6379
+ * @generated from protobuf enum value: MATCH_SCOPE_GLOBAL = 2;
6380
+ */
6381
+ MatchScope$1[MatchScope$1["GLOBAL"] = 2] = "GLOBAL";
6382
+ return MatchScope$1;
6383
+ }({});
6384
+ /**
6385
+ * Match type - how the match was found
6386
+ *
6387
+ * @generated from protobuf enum tusk.drift.core.v1.MatchType
6388
+ */
6389
+ let MatchType = /* @__PURE__ */ function(MatchType$1) {
6390
+ /**
6391
+ * @generated from protobuf enum value: MATCH_TYPE_UNSPECIFIED = 0;
6392
+ */
6393
+ MatchType$1[MatchType$1["UNSPECIFIED"] = 0] = "UNSPECIFIED";
6394
+ /**
6395
+ * @generated from protobuf enum value: MATCH_TYPE_INPUT_VALUE_HASH = 1;
6396
+ */
6397
+ MatchType$1[MatchType$1["INPUT_VALUE_HASH"] = 1] = "INPUT_VALUE_HASH";
6398
+ /**
6399
+ * @generated from protobuf enum value: MATCH_TYPE_INPUT_VALUE_HASH_REDUCED_SCHEMA = 2;
6400
+ */
6401
+ MatchType$1[MatchType$1["INPUT_VALUE_HASH_REDUCED_SCHEMA"] = 2] = "INPUT_VALUE_HASH_REDUCED_SCHEMA";
6402
+ /**
6403
+ * @generated from protobuf enum value: MATCH_TYPE_INPUT_SCHEMA_HASH = 3;
6404
+ */
6405
+ MatchType$1[MatchType$1["INPUT_SCHEMA_HASH"] = 3] = "INPUT_SCHEMA_HASH";
6406
+ /**
6407
+ * @generated from protobuf enum value: MATCH_TYPE_INPUT_SCHEMA_HASH_REDUCED_SCHEMA = 4;
6408
+ */
6409
+ MatchType$1[MatchType$1["INPUT_SCHEMA_HASH_REDUCED_SCHEMA"] = 4] = "INPUT_SCHEMA_HASH_REDUCED_SCHEMA";
6410
+ /**
6411
+ * @generated from protobuf enum value: MATCH_TYPE_FUZZY = 5;
6412
+ */
6413
+ MatchType$1[MatchType$1["FUZZY"] = 5] = "FUZZY";
6414
+ /**
6415
+ * @generated from protobuf enum value: MATCH_TYPE_FALLBACK = 6;
6416
+ */
6417
+ MatchType$1[MatchType$1["FALLBACK"] = 6] = "FALLBACK";
6418
+ return MatchType$1;
6419
+ }({});
6364
6420
  var Span$Type = class extends import_commonjs$6.MessageType {
6365
6421
  constructor() {
6366
6422
  super("tusk.drift.core.v1.Span", [
@@ -7007,6 +7063,157 @@ var Trace$Type = class extends import_commonjs$6.MessageType {
7007
7063
  * @generated MessageType for protobuf message tusk.drift.core.v1.Trace
7008
7064
  */
7009
7065
  const Trace = new Trace$Type();
7066
+ var SimilarityCandidate$Type = class extends import_commonjs$6.MessageType {
7067
+ constructor() {
7068
+ super("tusk.drift.core.v1.SimilarityCandidate", [{
7069
+ no: 1,
7070
+ name: "span_id",
7071
+ kind: "scalar",
7072
+ T: 9
7073
+ }, {
7074
+ no: 2,
7075
+ name: "score",
7076
+ kind: "scalar",
7077
+ T: 2
7078
+ }]);
7079
+ }
7080
+ create(value) {
7081
+ const message = globalThis.Object.create(this.messagePrototype);
7082
+ message.spanId = "";
7083
+ message.score = 0;
7084
+ if (value !== void 0) (0, import_commonjs$6.reflectionMergePartial)(this, message, value);
7085
+ return message;
7086
+ }
7087
+ internalBinaryRead(reader, length, options, target) {
7088
+ let message = target ?? this.create(), end = reader.pos + length;
7089
+ while (reader.pos < end) {
7090
+ let [fieldNo, wireType] = reader.tag();
7091
+ switch (fieldNo) {
7092
+ case 1:
7093
+ message.spanId = reader.string();
7094
+ break;
7095
+ case 2:
7096
+ message.score = reader.float();
7097
+ break;
7098
+ default:
7099
+ let u = options.readUnknownField;
7100
+ if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7101
+ let d = reader.skip(wireType);
7102
+ if (u !== false) (u === true ? import_commonjs$6.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7103
+ }
7104
+ }
7105
+ return message;
7106
+ }
7107
+ internalBinaryWrite(message, writer, options) {
7108
+ if (message.spanId !== "") writer.tag(1, import_commonjs$6.WireType.LengthDelimited).string(message.spanId);
7109
+ if (message.score !== 0) writer.tag(2, import_commonjs$6.WireType.Bit32).float(message.score);
7110
+ let u = options.writeUnknownFields;
7111
+ if (u !== false) (u == true ? import_commonjs$6.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7112
+ return writer;
7113
+ }
7114
+ };
7115
+ /**
7116
+ * @generated MessageType for protobuf message tusk.drift.core.v1.SimilarityCandidate
7117
+ */
7118
+ const SimilarityCandidate = new SimilarityCandidate$Type();
7119
+ var MatchLevel$Type = class extends import_commonjs$6.MessageType {
7120
+ constructor() {
7121
+ super("tusk.drift.core.v1.MatchLevel", [
7122
+ {
7123
+ no: 1,
7124
+ name: "match_type",
7125
+ kind: "enum",
7126
+ T: () => [
7127
+ "tusk.drift.core.v1.MatchType",
7128
+ MatchType,
7129
+ "MATCH_TYPE_"
7130
+ ]
7131
+ },
7132
+ {
7133
+ no: 2,
7134
+ name: "match_scope",
7135
+ kind: "enum",
7136
+ T: () => [
7137
+ "tusk.drift.core.v1.MatchScope",
7138
+ MatchScope,
7139
+ "MATCH_SCOPE_"
7140
+ ]
7141
+ },
7142
+ {
7143
+ no: 3,
7144
+ name: "match_description",
7145
+ kind: "scalar",
7146
+ T: 9
7147
+ },
7148
+ {
7149
+ no: 4,
7150
+ name: "similarity_score",
7151
+ kind: "scalar",
7152
+ opt: true,
7153
+ T: 2
7154
+ },
7155
+ {
7156
+ no: 5,
7157
+ name: "top_candidates",
7158
+ kind: "message",
7159
+ repeat: 2,
7160
+ T: () => SimilarityCandidate
7161
+ }
7162
+ ]);
7163
+ }
7164
+ create(value) {
7165
+ const message = globalThis.Object.create(this.messagePrototype);
7166
+ message.matchType = 0;
7167
+ message.matchScope = 0;
7168
+ message.matchDescription = "";
7169
+ message.topCandidates = [];
7170
+ if (value !== void 0) (0, import_commonjs$6.reflectionMergePartial)(this, message, value);
7171
+ return message;
7172
+ }
7173
+ internalBinaryRead(reader, length, options, target) {
7174
+ let message = target ?? this.create(), end = reader.pos + length;
7175
+ while (reader.pos < end) {
7176
+ let [fieldNo, wireType] = reader.tag();
7177
+ switch (fieldNo) {
7178
+ case 1:
7179
+ message.matchType = reader.int32();
7180
+ break;
7181
+ case 2:
7182
+ message.matchScope = reader.int32();
7183
+ break;
7184
+ case 3:
7185
+ message.matchDescription = reader.string();
7186
+ break;
7187
+ case 4:
7188
+ message.similarityScore = reader.float();
7189
+ break;
7190
+ case 5:
7191
+ message.topCandidates.push(SimilarityCandidate.internalBinaryRead(reader, reader.uint32(), options));
7192
+ break;
7193
+ default:
7194
+ let u = options.readUnknownField;
7195
+ if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7196
+ let d = reader.skip(wireType);
7197
+ if (u !== false) (u === true ? import_commonjs$6.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7198
+ }
7199
+ }
7200
+ return message;
7201
+ }
7202
+ internalBinaryWrite(message, writer, options) {
7203
+ if (message.matchType !== 0) writer.tag(1, import_commonjs$6.WireType.Varint).int32(message.matchType);
7204
+ if (message.matchScope !== 0) writer.tag(2, import_commonjs$6.WireType.Varint).int32(message.matchScope);
7205
+ if (message.matchDescription !== "") writer.tag(3, import_commonjs$6.WireType.LengthDelimited).string(message.matchDescription);
7206
+ if (message.similarityScore !== void 0) writer.tag(4, import_commonjs$6.WireType.Bit32).float(message.similarityScore);
7207
+ 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();
7208
+ let u = options.writeUnknownFields;
7209
+ if (u !== false) (u == true ? import_commonjs$6.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7210
+ return writer;
7211
+ }
7212
+ };
7213
+ /**
7214
+ * @generated MessageType for protobuf message tusk.drift.core.v1.MatchLevel
7215
+ */
7216
+ const MatchLevel = new MatchLevel$Type();
7010
7217
 
7011
7218
  //#endregion
7012
7219
  //#region src/core/utils/protobufUtils.ts
@@ -7068,6 +7275,50 @@ function valueToProtobufValue(value) {
7068
7275
  stringValue: String(value)
7069
7276
  } });
7070
7277
  }
7278
+ /**
7279
+ * Human-readable labels for MatchType enum values
7280
+ */
7281
+ const MATCH_TYPE_LABELS = {
7282
+ [MatchType.UNSPECIFIED]: "UNSPECIFIED",
7283
+ [MatchType.INPUT_VALUE_HASH]: "INPUT_VALUE_HASH",
7284
+ [MatchType.INPUT_VALUE_HASH_REDUCED_SCHEMA]: "INPUT_VALUE_HASH_REDUCED_SCHEMA",
7285
+ [MatchType.INPUT_SCHEMA_HASH]: "INPUT_SCHEMA_HASH",
7286
+ [MatchType.INPUT_SCHEMA_HASH_REDUCED_SCHEMA]: "INPUT_SCHEMA_HASH_REDUCED_SCHEMA",
7287
+ [MatchType.FUZZY]: "FUZZY",
7288
+ [MatchType.FALLBACK]: "FALLBACK"
7289
+ };
7290
+ /**
7291
+ * Human-readable labels for MatchScope enum values
7292
+ */
7293
+ const MATCH_SCOPE_LABELS = {
7294
+ [MatchScope.UNSPECIFIED]: "UNSPECIFIED",
7295
+ [MatchScope.TRACE]: "TRACE",
7296
+ [MatchScope.GLOBAL]: "GLOBAL"
7297
+ };
7298
+ /**
7299
+ * Converts a MatchType enum to a human-readable label
7300
+ */
7301
+ function getMatchTypeLabel(matchType) {
7302
+ return MATCH_TYPE_LABELS[matchType] ?? `UNKNOWN(${matchType})`;
7303
+ }
7304
+ /**
7305
+ * Converts a MatchScope enum to a human-readable label
7306
+ */
7307
+ function getMatchScopeLabel(matchScope) {
7308
+ return MATCH_SCOPE_LABELS[matchScope] ?? `UNKNOWN(${matchScope})`;
7309
+ }
7310
+ /**
7311
+ * Formats a matchLevel object as a concise, readable string for logging
7312
+ */
7313
+ function formatMatchLevelForLog(matchLevel) {
7314
+ if (!matchLevel) return "No match level info";
7315
+ const matchType = matchLevel.matchType ?? MatchType.UNSPECIFIED;
7316
+ const matchScope = matchLevel.matchScope ?? MatchScope.UNSPECIFIED;
7317
+ let result = `[${getMatchTypeLabel(matchType)}] scope=${getMatchScopeLabel(matchScope)}`;
7318
+ if (matchLevel.matchDescription) result += ` - "${matchLevel.matchDescription}"`;
7319
+ if (matchLevel.similarityScore !== void 0) result += ` (score: ${matchLevel.similarityScore})`;
7320
+ return result;
7321
+ }
7071
7322
 
7072
7323
  //#endregion
7073
7324
  //#region src/core/utils/OriginalGlobalUtils.ts
@@ -8335,7 +8586,7 @@ async function findMockResponseAsync({ mockRequestData, tuskDrift, inputValueSch
8335
8586
  return null;
8336
8587
  }
8337
8588
  const responseBody = mockResponse.response?.response?.body;
8338
- logger.debug(`Found ${outboundSpan.traceId} mock response:`, responseBody, { timestamp: mockResponse.response?.timestamp });
8589
+ logger.debug(`Found ${outboundSpan.traceId} mock response:`);
8339
8590
  if (mockResponse.response?.timestamp) DateTracker.updateLatestTimestamp(replayTraceId || "", mockResponse.response.timestamp);
8340
8591
  return { result: responseBody };
8341
8592
  } catch (error) {
@@ -8357,7 +8608,7 @@ function findMockResponseSync({ mockRequestData, tuskDrift, inputValueSchemaMerg
8357
8608
  return null;
8358
8609
  }
8359
8610
  const responseBody = mockResponse.response?.response?.body;
8360
- logger.debug(`Found ${outboundSpan.traceId} mock response and timestamp:`, responseBody, { timestamp: mockResponse.response?.timestamp });
8611
+ logger.debug(`Found ${outboundSpan.traceId} mock response:`);
8361
8612
  if (mockResponse.response?.timestamp) DateTracker.updateLatestTimestamp(replayTraceId || "", mockResponse.response.timestamp);
8362
8613
  return { result: responseBody };
8363
8614
  } catch (error) {
@@ -9981,7 +10232,7 @@ var require_commonjs$1 = /* @__PURE__ */ __commonJS({ "node_modules/@protobuf-ts
9981
10232
  }) });
9982
10233
 
9983
10234
  //#endregion
9984
- //#region node_modules/@use-tusk/drift-schemas/dist/span_export_service-CmkFvTqD.js
10235
+ //#region node_modules/@use-tusk/drift-schemas/dist/span_export_service-RmRqNxn1.js
9985
10236
  var import_commonjs$4 = /* @__PURE__ */ __toESM(require_commonjs$1(), 1);
9986
10237
  var import_commonjs$5 = /* @__PURE__ */ __toESM(require_commonjs$2(), 1);
9987
10238
  var ExportSpansRequest$Type = class extends import_commonjs$5.MessageType {
@@ -33477,7 +33728,7 @@ var require_src = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/sdk-
33477
33728
  //#endregion
33478
33729
  //#region package.json
33479
33730
  var import_src$1 = /* @__PURE__ */ __toESM(require_src(), 1);
33480
- var version = "0.1.25";
33731
+ var version = "0.1.26";
33481
33732
 
33482
33733
  //#endregion
33483
33734
  //#region src/version.ts
@@ -33485,7 +33736,7 @@ const SDK_VERSION = version;
33485
33736
  const MIN_CLI_VERSION = "0.1.0";
33486
33737
 
33487
33738
  //#endregion
33488
- //#region node_modules/@use-tusk/drift-schemas/dist/communication-BY2KZhrg.js
33739
+ //#region node_modules/@use-tusk/drift-schemas/dist/communication-CVqe2frO.js
33489
33740
  var import_commonjs = /* @__PURE__ */ __toESM(require_commonjs$1(), 1);
33490
33741
  var import_commonjs$1 = /* @__PURE__ */ __toESM(require_commonjs$2(), 1);
33491
33742
  /**
@@ -33827,6 +34078,12 @@ var GetMockResponse$Type = class extends import_commonjs$1.MessageType {
33827
34078
  name: "matched_at",
33828
34079
  kind: "message",
33829
34080
  T: () => Timestamp
34081
+ },
34082
+ {
34083
+ no: 9,
34084
+ name: "match_level",
34085
+ kind: "message",
34086
+ T: () => MatchLevel
33830
34087
  }
33831
34088
  ]);
33832
34089
  }
@@ -33869,6 +34126,9 @@ var GetMockResponse$Type = class extends import_commonjs$1.MessageType {
33869
34126
  case 8:
33870
34127
  message.matchedAt = Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.matchedAt);
33871
34128
  break;
34129
+ case 9:
34130
+ message.matchLevel = MatchLevel.internalBinaryRead(reader, reader.uint32(), options, message.matchLevel);
34131
+ break;
33872
34132
  default:
33873
34133
  let u = options.readUnknownField;
33874
34134
  if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
@@ -33887,6 +34147,7 @@ var GetMockResponse$Type = class extends import_commonjs$1.MessageType {
33887
34147
  if (message.errorCode !== "") writer.tag(6, import_commonjs$1.WireType.LengthDelimited).string(message.errorCode);
33888
34148
  if (message.matchedSpanId !== "") writer.tag(7, import_commonjs$1.WireType.LengthDelimited).string(message.matchedSpanId);
33889
34149
  if (message.matchedAt) Timestamp.internalBinaryWrite(message.matchedAt, writer.tag(8, import_commonjs$1.WireType.LengthDelimited).fork(), options).join();
34150
+ if (message.matchLevel) MatchLevel.internalBinaryWrite(message.matchLevel, writer.tag(9, import_commonjs$1.WireType.LengthDelimited).fork(), options).join();
33890
34151
  let u = options.writeUnknownFields;
33891
34152
  if (u !== false) (u == true ? import_commonjs$1.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
33892
34153
  return writer;
@@ -34952,7 +35213,7 @@ var ProtobufCommunicator = class ProtobufCommunicator {
34952
35213
  if (struct.fields && struct.fields["response"]) {
34953
35214
  const responseValue = Value.toJson(struct.fields["response"]);
34954
35215
  if (responseValue) {
34955
- logger.debug("[ProtobufCommunicator] Extracted response data:", JSON.stringify(responseValue, null, 2));
35216
+ logger.debug("[ProtobufCommunicator] Extracted response data:", JSON.stringify(responseValue, null, 2), "\nMatch level:", formatMatchLevelForLog(mockResponse.matchLevel));
34956
35217
  return responseValue;
34957
35218
  }
34958
35219
  }
@@ -35423,7 +35684,7 @@ var TuskDriftCore = class TuskDriftCore {
35423
35684
  logger.error("Failed to send inbound replay span:", e);
35424
35685
  }
35425
35686
  }
35426
- createMockRequestCore(mockRequest) {
35687
+ createMockRequestCore() {
35427
35688
  if (!this.communicator || this.mode !== TuskDriftMode.REPLAY) {
35428
35689
  logger.error("Cannot request mock: not in replay mode or no CLI connection", this.mode, this.communicator);
35429
35690
  return {
@@ -35438,7 +35699,7 @@ var TuskDriftCore = class TuskDriftCore {
35438
35699
  logger.debug("Waiting for CLI connection to be established");
35439
35700
  await this.cliConnectionPromise;
35440
35701
  }
35441
- const mockRequestCore = this.createMockRequestCore(mockRequest);
35702
+ const mockRequestCore = this.createMockRequestCore();
35442
35703
  if (mockRequestCore) return mockRequestCore;
35443
35704
  return this.requestMockFromCLIAsync(mockRequest);
35444
35705
  }
@@ -35452,12 +35713,10 @@ var TuskDriftCore = class TuskDriftCore {
35452
35713
  }
35453
35714
  try {
35454
35715
  logger.debug("Sending protobuf request to CLI (async)", JSON.stringify(mockRequest, null, 2));
35455
- const response = await this.communicator.requestMockAsync({
35716
+ return await this.communicator.requestMockAsync({
35456
35717
  testId: mockRequest.testId,
35457
35718
  outboundSpan: mockRequest.outboundSpan
35458
35719
  });
35459
- logger.debug("Received protobuf response from CLI", JSON.stringify(response, null, 2));
35460
- return response;
35461
35720
  } catch (error) {
35462
35721
  logger.error("Error sending protobuf request to CLI:", error);
35463
35722
  return {
@@ -35471,7 +35730,7 @@ var TuskDriftCore = class TuskDriftCore {
35471
35730
  logger.error("Requesting sync mock but CLI is not ready yet");
35472
35731
  throw new Error("Requesting sync mock but CLI is not ready yet");
35473
35732
  }
35474
- const mockRequestCore = this.createMockRequestCore(mockRequest);
35733
+ const mockRequestCore = this.createMockRequestCore();
35475
35734
  if (mockRequestCore) return mockRequestCore;
35476
35735
  return this.requestMockFromCLISync(mockRequest);
35477
35736
  }
@@ -35485,12 +35744,10 @@ var TuskDriftCore = class TuskDriftCore {
35485
35744
  }
35486
35745
  try {
35487
35746
  logger.debug("Sending protobuf request to CLI (sync)", mockRequest);
35488
- const response = this.communicator.requestMockSync({
35747
+ return this.communicator.requestMockSync({
35489
35748
  testId: mockRequest.testId,
35490
35749
  outboundSpan: mockRequest.outboundSpan
35491
35750
  });
35492
- logger.debug("Received protobuf response from CLI", response);
35493
- return response;
35494
35751
  } catch (error) {
35495
35752
  logger.error("Error sending protobuf request to CLI:", error);
35496
35753
  return {