@cadenza.io/service 1.10.6 → 1.10.7

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.mts CHANGED
@@ -130,7 +130,7 @@ declare class DatabaseTask extends DeputyTask {
130
130
  }
131
131
 
132
132
  interface ServiceInstanceDescriptor {
133
- id: string;
133
+ uuid: string;
134
134
  address: string;
135
135
  port: number;
136
136
  serviceName: string;
package/dist/index.d.ts CHANGED
@@ -130,7 +130,7 @@ declare class DatabaseTask extends DeputyTask {
130
130
  }
131
131
 
132
132
  interface ServiceInstanceDescriptor {
133
- id: string;
133
+ uuid: string;
134
134
  address: string;
135
135
  port: number;
136
136
  serviceName: string;
package/dist/index.js CHANGED
@@ -339,11 +339,11 @@ var ServiceRegistry = class _ServiceRegistry {
339
339
  (ctx, emit) => {
340
340
  var _a2;
341
341
  const { service_instance } = ctx;
342
- const { id, serviceName, address, port, exposed } = service_instance;
342
+ const { uuid: uuid4, serviceName, address, port, exposed } = service_instance;
343
343
  if (!this.instances.has(serviceName))
344
344
  this.instances.set(serviceName, []);
345
345
  const instances = this.instances.get(serviceName);
346
- const existing = instances.find((i) => i.id === id);
346
+ const existing = instances.find((i) => i.uuid === uuid4);
347
347
  if (existing) {
348
348
  Object.assign(existing, service_instance);
349
349
  } else {
@@ -358,7 +358,7 @@ var ServiceRegistry = class _ServiceRegistry {
358
358
  }
359
359
  emit("meta.service_registry.dependee_registered", {
360
360
  serviceName,
361
- serviceInstanceId: id,
361
+ serviceInstanceId: uuid4,
362
362
  serviceAddress: address,
363
363
  servicePort: port,
364
364
  protocol: exposed ? "https" : "http",
@@ -370,7 +370,7 @@ var ServiceRegistry = class _ServiceRegistry {
370
370
  instance.clientCreated = true;
371
371
  emit("meta.service_registry.dependee_registered", {
372
372
  serviceName,
373
- serviceInstanceId: id,
373
+ serviceInstanceId: uuid4,
374
374
  serviceAddress: address,
375
375
  servicePort: port,
376
376
  protocol: exposed ? "https" : "http",
@@ -434,7 +434,7 @@ var ServiceRegistry = class _ServiceRegistry {
434
434
  const instanceId = ctx.__serviceInstanceId;
435
435
  const serviceName = ctx.__serviceName;
436
436
  const instances = this.instances.get(serviceName);
437
- const instance = instances == null ? void 0 : instances.find((i) => i.id === instanceId);
437
+ const instance = instances == null ? void 0 : instances.find((i) => i.uuid === instanceId);
438
438
  if (instance) {
439
439
  instance.health = ctx.health;
440
440
  instance.numberOfRunningGraphs = ctx.numberOfRunningGraphs;
@@ -489,7 +489,7 @@ var ServiceRegistry = class _ServiceRegistry {
489
489
  const { __id } = context;
490
490
  let instance;
491
491
  for (const instances of this.instances.values()) {
492
- instance = instances.find((i) => i.id === __id);
492
+ instance = instances.find((i) => i.uuid === __id);
493
493
  if (instance) break;
494
494
  }
495
495
  return __spreadProps(__spreadValues({}, context), { __instance: instance });
@@ -567,7 +567,7 @@ var ServiceRegistry = class _ServiceRegistry {
567
567
  return context;
568
568
  }
569
569
  let instancesToTry = instances.filter(
570
- (i) => !(__triedInstances == null ? void 0 : __triedInstances.includes(i.id))
570
+ (i) => !(__triedInstances == null ? void 0 : __triedInstances.includes(i.uuid))
571
571
  );
572
572
  if (instancesToTry.length === 0) {
573
573
  if (this.useSocket) {
@@ -584,9 +584,9 @@ var ServiceRegistry = class _ServiceRegistry {
584
584
  if (retries > 0) {
585
585
  selected = instancesToTry[Math.floor(Math.random() * instancesToTry.length)];
586
586
  }
587
- context.__instance = selected.id;
587
+ context.__instance = selected.uuid;
588
588
  context.__triedInstances = triedInstances;
589
- context.__triedInstances.push(selected.id);
589
+ context.__triedInstances.push(selected.uuid);
590
590
  context.__retries = retries;
591
591
  if (this.useSocket) {
592
592
  emit(
@@ -625,7 +625,7 @@ var ServiceRegistry = class _ServiceRegistry {
625
625
  errored: true
626
626
  };
627
627
  }
628
- const self2 = (_a2 = this.instances.get(this.serviceName)) == null ? void 0 : _a2.find((i) => i.id === this.serviceInstanceId);
628
+ const self2 = (_a2 = this.instances.get(this.serviceName)) == null ? void 0 : _a2.find((i) => i.uuid === this.serviceInstanceId);
629
629
  return __spreadProps(__spreadValues({}, ctx), {
630
630
  __status: "ok",
631
631
  __numberOfRunningGraphs: (_b2 = self2 == null ? void 0 : self2.numberOfRunningGraphs) != null ? _b2 : 0,
@@ -1352,6 +1352,12 @@ var SocketController = class _SocketController {
1352
1352
  const profile = (_b2 = ctx.__securityProfile) != null ? _b2 : "medium";
1353
1353
  server.use((socket, next) => {
1354
1354
  var _a3;
1355
+ console.log(
1356
+ "SocketServer: middleware",
1357
+ socket.handshake.headers.origin,
1358
+ profile,
1359
+ ctx.__networkType
1360
+ );
1355
1361
  const origin = socket.handshake.headers.origin;
1356
1362
  const allowedOrigins = ["*"];
1357
1363
  const networkType = (_a3 = ctx.__networkType) != null ? _a3 : "internal";
@@ -1369,11 +1375,16 @@ var SocketController = class _SocketController {
1369
1375
  socket.use((packet, next2) => {
1370
1376
  limiter.consume(socket.handshake.address).then(() => next2()).catch((rej) => {
1371
1377
  if (rej.msBeforeNext > 0) {
1378
+ console.log(
1379
+ "SocketServer: Rate limit exceeded",
1380
+ rej.msBeforeNext / 1e3
1381
+ );
1372
1382
  socket.emit("error", {
1373
1383
  message: "Rate limit exceeded",
1374
1384
  retryAfter: rej.msBeforeNext / 1e3
1375
1385
  });
1376
1386
  } else {
1387
+ console.log("SocketServer: Rate limit exceeded, blocked");
1377
1388
  socket.disconnect(true);
1378
1389
  }
1379
1390
  });
@@ -1389,7 +1400,9 @@ var SocketController = class _SocketController {
1389
1400
  }
1390
1401
  return data;
1391
1402
  };
1403
+ console.log("SocketServer: Sanitizing", packet[1]);
1392
1404
  packet[1] = sanitize(packet[1]);
1405
+ console.log("SocketServer: Sanitized", packet[1]);
1393
1406
  }
1394
1407
  next2();
1395
1408
  });