@cadenza.io/service 2.2.2 → 2.2.4

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
@@ -329,6 +329,9 @@ var ServiceRegistry = class _ServiceRegistry {
329
329
  } else {
330
330
  instances.push(serviceInstance);
331
331
  }
332
+ if (this.serviceName === serviceName) {
333
+ return false;
334
+ }
332
335
  if (!isFrontend && this.deputies.has(serviceName) || this.remoteSignals.has(serviceName)) {
333
336
  const clientCreated = instances?.some(
334
337
  (i) => i.address === address && i.port === port && i.clientCreated && i.isActive
@@ -455,24 +458,25 @@ var ServiceRegistry = class _ServiceRegistry {
455
458
  this.handleServiceHandshakeTask = CadenzaService.createMetaTask(
456
459
  "Handle service handshake",
457
460
  (ctx, emit) => {
458
- const { serviceName, serviceAddress, servicePort } = ctx;
461
+ const { serviceName, serviceInstanceId } = ctx;
459
462
  const serviceInstances = this.instances.get(serviceName);
460
- const instances = serviceInstances?.filter(
461
- (i) => i.address === serviceAddress && i.port === servicePort
463
+ const instance = serviceInstances?.find(
464
+ (i) => i.uuid === serviceInstanceId
462
465
  );
463
- for (const instance of instances ?? []) {
464
- instance.isActive = true;
465
- instance.isNonResponsive = false;
466
- emit("global.meta.service_registry.service_handshake", {
467
- data: {
468
- isActive: instance.isActive,
469
- isNonResponsive: instance.isNonResponsive
470
- },
471
- filter: {
472
- uuid: instance.uuid
473
- }
474
- });
466
+ if (!instance) {
467
+ return false;
475
468
  }
469
+ instance.isActive = true;
470
+ instance.isNonResponsive = false;
471
+ emit("global.meta.service_registry.service_handshake", {
472
+ data: {
473
+ isActive: instance.isActive,
474
+ isNonResponsive: instance.isNonResponsive
475
+ },
476
+ filter: {
477
+ uuid: instance.uuid
478
+ }
479
+ });
476
480
  return true;
477
481
  },
478
482
  "Handles service handshake"
@@ -2462,11 +2466,8 @@ var DatabaseController = class _DatabaseController {
2462
2466
  constructor() {
2463
2467
  this.databaseName = "";
2464
2468
  this.dbClient = new import_pg.Pool({
2465
- user: process.env.DATABASE_USER ?? "postgres",
2466
- host: process.env.DATABASE_ADDRESS ?? "localhost",
2467
- port: parseInt(process.env.DATABASE_PORT ?? "5432"),
2469
+ connectionString: process.env.DATABASE_ADDRESS ?? "",
2468
2470
  database: "postgres",
2469
- password: process.env.DATABASE_PASSWORD ?? "03gibnEF",
2470
2471
  ssl: {
2471
2472
  rejectUnauthorized: false
2472
2473
  // ← This bypasses the chain validation error
@@ -2489,20 +2490,15 @@ var DatabaseController = class _DatabaseController {
2489
2490
  );
2490
2491
  }
2491
2492
  console.log(`Creating database ${databaseName}`, {
2492
- user: process.env.DATABASE_USER ?? "postgres",
2493
- host: process.env.DATABASE_ADDRESS ?? "localhost",
2494
- port: parseInt(process.env.DATABASE_PORT ?? "5432"),
2493
+ connectionString: process.env.DATABASE_ADDRESS ?? "",
2495
2494
  database: "postgres",
2496
2495
  password: process.env.DATABASE_PASSWORD ?? "03gibnEF"
2497
2496
  });
2498
2497
  await this.dbClient.query(`CREATE DATABASE ${databaseName}`);
2499
2498
  console.log(`Database ${databaseName} created`);
2500
2499
  this.dbClient = new import_pg.Pool({
2501
- user: process.env.DATABASE_USER ?? "postgres",
2502
- host: process.env.DATABASE_ADDRESS ?? "localhost",
2503
- port: parseInt(process.env.DATABASE_PORT ?? "5432"),
2500
+ connectionString: process.env.DATABASE_ADDRESS ?? "",
2504
2501
  database: databaseName,
2505
- password: process.env.DATABASE_PASSWORD ?? "03gibnEF",
2506
2502
  ssl: {
2507
2503
  rejectUnauthorized: false
2508
2504
  // ← This bypasses the chain validation error
@@ -3284,7 +3280,10 @@ var DatabaseController = class _DatabaseController {
3284
3280
  async updateFunction(tableName, context) {
3285
3281
  const { data, filter = {}, transaction = true } = context;
3286
3282
  if (!data || Object.keys(data).length === 0) {
3287
- return { errored: true, __error: "No data provided for update" };
3283
+ return {
3284
+ errored: true,
3285
+ __error: `No data provided for update of ${tableName}`
3286
+ };
3288
3287
  }
3289
3288
  let resultContext = {};
3290
3289
  const client = transaction ? await this.getClient() : this.dbClient;