@monorise/core 4.1.0 → 4.2.0

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.ts CHANGED
@@ -4599,12 +4599,14 @@ declare class UpsertEntityController {
4599
4599
  }
4600
4600
 
4601
4601
  declare class MutualService {
4602
+ private EntityConfig;
4602
4603
  private entityRepository;
4603
4604
  private mutualRepository;
4604
4605
  private publishEvent;
4605
4606
  private ddbUtils;
4606
4607
  private entityServiceLifeCycle;
4607
- constructor(entityRepository: EntityRepository, mutualRepository: MutualRepository, publishEvent: typeof publishEvent, ddbUtils: DbUtils, entityServiceLifeCycle: EntityServiceLifeCycle);
4608
+ constructor(EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>, entityRepository: EntityRepository, mutualRepository: MutualRepository, publishEvent: typeof publishEvent, ddbUtils: DbUtils, entityServiceLifeCycle: EntityServiceLifeCycle);
4609
+ private getMutualDataSchema;
4608
4610
  createMutual: <B extends Entity$2, T extends Entity$2, A extends Entity$2>({ byEntityType, byEntityId, entityType, entityId, mutualPayload, accountId, options, }: {
4609
4611
  byEntityType: B;
4610
4612
  byEntityId: string;
@@ -4623,13 +4625,17 @@ declare class MutualService {
4623
4625
  ExpressionAttributeValues?: Record<string, AttributeValue>;
4624
4626
  };
4625
4627
  }) => Promise<{
4626
- mutual: Mutual<B, T, Record<string, any>>;
4628
+ mutual: Mutual<B, T, {
4629
+ [x: string]: any;
4630
+ }>;
4627
4631
  eventPayload: {
4628
4632
  byEntityType: B;
4629
4633
  byEntityId: string;
4630
4634
  entityType: T;
4631
4635
  entityId: string;
4632
- parsedMutualPayload: Record<string, any>;
4636
+ parsedMutualPayload: {
4637
+ [x: string]: any;
4638
+ };
4633
4639
  accountId: string | string[] | undefined;
4634
4640
  publishedAt: string;
4635
4641
  };
package/dist/index.js CHANGED
@@ -1225,7 +1225,14 @@ var MutualRepository = class extends Repository {
1225
1225
  }
1226
1226
  getMutual(byEntityType, byEntityId, entityType, entityId, opts) {
1227
1227
  return __async(this, null, function* () {
1228
- var _a, _b;
1228
+ var _a, _b, _c, _d, _e, _f;
1229
+ console.log("[MONORISE_DEBUG] getMutual start:", {
1230
+ byEntityType,
1231
+ byEntityId,
1232
+ entityType,
1233
+ entityId,
1234
+ opts
1235
+ });
1229
1236
  const mutual = new Mutual(
1230
1237
  byEntityType,
1231
1238
  byEntityId,
@@ -1235,6 +1242,11 @@ var MutualRepository = class extends Repository {
1235
1242
  {},
1236
1243
  {}
1237
1244
  );
1245
+ console.log("[MONORISE_DEBUG] getMutual querying:", {
1246
+ byFullEntityId: mutual.byFullEntityId,
1247
+ fullEntityId: mutual.fullEntityId,
1248
+ tableName: this.TABLE_NAME
1249
+ });
1238
1250
  const resp = yield this.dynamodbClient.query({
1239
1251
  TableName: this.TABLE_NAME,
1240
1252
  KeyConditionExpression: "#PK = :PK and begins_with(#SK, :SK)",
@@ -1251,9 +1263,14 @@ var MutualRepository = class extends Repository {
1251
1263
  },
1252
1264
  Limit: 1
1253
1265
  });
1266
+ console.log("[MONORISE_DEBUG] getMutual query result:", {
1267
+ hasItems: !!((_a = resp.Items) == null ? void 0 : _a.length),
1268
+ itemCount: (_c = (_b = resp.Items) == null ? void 0 : _b.length) != null ? _c : 0,
1269
+ hasLastEvaluatedKey: !!resp.LastEvaluatedKey
1270
+ });
1254
1271
  let mutualMetadata = null;
1255
1272
  if (opts == null ? void 0 : opts.isFromMetadata) {
1256
- const tempMutual = Mutual.fromItem((_a = resp.Items) == null ? void 0 : _a[0]);
1273
+ const tempMutual = Mutual.fromItem((_d = resp.Items) == null ? void 0 : _d[0]);
1257
1274
  const respMetadataMutual = yield this.dynamodbClient.getItem({
1258
1275
  TableName: this.TABLE_NAME,
1259
1276
  Key: tempMutual.mainKeys(),
@@ -1261,12 +1278,28 @@ var MutualRepository = class extends Repository {
1261
1278
  });
1262
1279
  mutualMetadata = Mutual.fromItem(respMetadataMutual.Item);
1263
1280
  }
1264
- return mutualMetadata || Mutual.fromItem((_b = resp.Items) == null ? void 0 : _b[0]);
1281
+ console.log("[MONORISE_DEBUG] getMutual fromItem:", {
1282
+ hasMutualMetadata: !!mutualMetadata,
1283
+ hasFirstItem: !!((_e = resp.Items) == null ? void 0 : _e[0])
1284
+ });
1285
+ const result = mutualMetadata || Mutual.fromItem((_f = resp.Items) == null ? void 0 : _f[0]);
1286
+ console.log("[MONORISE_DEBUG] getMutual complete:", {
1287
+ mutualId: result.mutualId,
1288
+ byEntityType: result.byEntityType,
1289
+ entityType: result.entityType
1290
+ });
1291
+ return result;
1265
1292
  });
1266
1293
  }
1267
1294
  checkMutualExist(byEntityType, byEntityId, entityType, entityId) {
1268
1295
  return __async(this, null, function* () {
1269
- var _a;
1296
+ var _a, _b;
1297
+ console.log("[MONORISE_DEBUG] checkMutualExist:", {
1298
+ byEntityType,
1299
+ byEntityId,
1300
+ entityType,
1301
+ entityId
1302
+ });
1270
1303
  const mutual = new Mutual(
1271
1304
  byEntityType,
1272
1305
  byEntityId,
@@ -1281,7 +1314,11 @@ var MutualRepository = class extends Repository {
1281
1314
  Key: mutual.subKeys(),
1282
1315
  ProjectionExpression: "PK, SK, expiresAt"
1283
1316
  });
1284
- if (resp.Item && !((_a = resp.Item) == null ? void 0 : _a.expiresAt)) {
1317
+ console.log("[MONORISE_DEBUG] checkMutualExist result:", {
1318
+ hasItem: !!resp.Item,
1319
+ hasExpiresAt: !!((_a = resp.Item) == null ? void 0 : _a.expiresAt)
1320
+ });
1321
+ if (resp.Item && !((_b = resp.Item) == null ? void 0 : _b.expiresAt)) {
1285
1322
  throw new StandardError(
1286
1323
  StandardErrorCode.MUTUAL_EXISTS,
1287
1324
  "Entities are already linked"
@@ -1291,6 +1328,14 @@ var MutualRepository = class extends Repository {
1291
1328
  });
1292
1329
  }
1293
1330
  createMutualTransactItems(mutual, opts) {
1331
+ console.log("[MONORISE_DEBUG] createMutualTransactItems:", {
1332
+ mutualId: mutual.mutualId,
1333
+ byEntityType: mutual.byEntityType,
1334
+ byEntityId: mutual.byEntityId,
1335
+ entityType: mutual.entityType,
1336
+ entityId: mutual.entityId,
1337
+ hasOpts: !!opts
1338
+ });
1294
1339
  const TransactItems = [
1295
1340
  {
1296
1341
  Put: {
@@ -1365,10 +1410,19 @@ var MutualRepository = class extends Repository {
1365
1410
  }
1366
1411
  updateMutual(byEntityType, byEntityId, entityType, entityId, toUpdate, opts) {
1367
1412
  return __async(this, null, function* () {
1368
- var _a;
1413
+ var _a, _b;
1414
+ console.log("[MONORISE_DEBUG] updateMutual repository start:", {
1415
+ byEntityType,
1416
+ byEntityId,
1417
+ entityType,
1418
+ entityId,
1419
+ toUpdateKeys: Object.keys(toUpdate),
1420
+ opts
1421
+ });
1369
1422
  const returnUpdatedValue = (_a = opts == null ? void 0 : opts.returnUpdatedValue) != null ? _a : false;
1370
1423
  const errorContext = {};
1371
1424
  try {
1425
+ console.log("[MONORISE_DEBUG] updateMutual fetching mutual...");
1372
1426
  const mutual = yield this.getMutual(
1373
1427
  byEntityType,
1374
1428
  byEntityId,
@@ -1376,6 +1430,12 @@ var MutualRepository = class extends Repository {
1376
1430
  entityId,
1377
1431
  { ProjectionExpression: PROJECTION_EXPRESSION.NO_DATA }
1378
1432
  );
1433
+ console.log("[MONORISE_DEBUG] updateMutual mutual found:", {
1434
+ mutualId: mutual.mutualId,
1435
+ mainPk: mutual.mainPk,
1436
+ byFullEntityId: mutual.byFullEntityId,
1437
+ fullEntityId: mutual.fullEntityId
1438
+ });
1379
1439
  const currentDatetime = (/* @__PURE__ */ new Date()).toISOString();
1380
1440
  const toUpdateExpressions = this.toUpdate(
1381
1441
  __spreadValues({
@@ -1383,6 +1443,11 @@ var MutualRepository = class extends Repository {
1383
1443
  }, toUpdate),
1384
1444
  { maxLevel: opts == null ? void 0 : opts.maxObjectUpdateLevel }
1385
1445
  );
1446
+ console.log("[MONORISE_DEBUG] updateMutual update expression:", {
1447
+ UpdateExpression: toUpdateExpressions.UpdateExpression,
1448
+ ExpressionAttributeNames: toUpdateExpressions.ExpressionAttributeNames,
1449
+ hasExpressionAttributeValues: !!toUpdateExpressions.ExpressionAttributeValues
1450
+ });
1386
1451
  const updateExpression = {
1387
1452
  ConditionExpression: (opts == null ? void 0 : opts.ConditionExpression) || "attribute_exists(PK)",
1388
1453
  UpdateExpression: toUpdateExpressions.UpdateExpression,
@@ -1416,18 +1481,33 @@ var MutualRepository = class extends Repository {
1416
1481
  }
1417
1482
  ];
1418
1483
  errorContext.TransactItems = TransactItems;
1484
+ console.log("[MONORISE_DEBUG] updateMutual transact items prepared:", {
1485
+ itemCount: TransactItems.length,
1486
+ tableName: this.TABLE_NAME
1487
+ });
1488
+ console.log("[MONORISE_DEBUG] updateMutual executing transaction...");
1419
1489
  yield this.ddbUtils.executeTransactWrite({ TransactItems });
1490
+ console.log("[MONORISE_DEBUG] updateMutual transaction succeeded");
1420
1491
  if (!returnUpdatedValue) {
1492
+ console.log("[MONORISE_DEBUG] updateMutual returning (no value)");
1421
1493
  return;
1422
1494
  }
1495
+ console.log("[MONORISE_DEBUG] updateMutual fetching updated mutual...");
1423
1496
  const updatedMutual = yield this.getMutual(
1424
1497
  byEntityType,
1425
1498
  byEntityId,
1426
1499
  entityType,
1427
1500
  entityId
1428
1501
  );
1502
+ console.log("[MONORISE_DEBUG] updateMutual repository complete");
1429
1503
  return updatedMutual;
1430
1504
  } catch (err) {
1505
+ console.error("[MONORISE_DEBUG] updateMutual repository error:", {
1506
+ errorName: (_b = err == null ? void 0 : err.constructor) == null ? void 0 : _b.name,
1507
+ errorMessage: err == null ? void 0 : err.message,
1508
+ errorCode: err == null ? void 0 : err.code,
1509
+ isStandardError: err instanceof StandardError
1510
+ });
1431
1511
  if (err instanceof StandardError && err.code === StandardErrorCode.CONDITIONAL_CHECK_FAILED) {
1432
1512
  throw new StandardError(
1433
1513
  StandardErrorCode.MUTUAL_NOT_FOUND,
@@ -2162,6 +2242,7 @@ var getDependencies = () => {
2162
2242
  // middlewares/general-error-handler.ts
2163
2243
  var factory2 = createFactory2();
2164
2244
  var generalErrorHandler = (dependencies = getDependencies()) => factory2.createMiddleware((c) => __async(null, null, function* () {
2245
+ var _a, _b, _c, _d;
2165
2246
  if (c.error) {
2166
2247
  const { nanoid: nanoid2, publishErrorEvent: publishErrorEvent2 } = dependencies;
2167
2248
  const errorId = nanoid2();
@@ -2174,12 +2255,21 @@ var generalErrorHandler = (dependencies = getDependencies()) => factory2.createM
2174
2255
  body,
2175
2256
  error: c.error
2176
2257
  });
2177
- console.warn(
2178
- JSON.stringify({
2179
- message: "INTERNAL_SERVER_EXCEPTION",
2180
- details: c.error
2181
- })
2182
- );
2258
+ const error = c.error;
2259
+ console.warn("[MONORISE_DEBUG] INTERNAL_SERVER_EXCEPTION:", {
2260
+ errorId,
2261
+ method: c.req.method,
2262
+ path: c.req.path,
2263
+ errorName: error == null ? void 0 : error.name,
2264
+ errorMessage: error == null ? void 0 : error.message,
2265
+ errorCode: error == null ? void 0 : error.code,
2266
+ errorStack: error == null ? void 0 : error.stack,
2267
+ errorConstructor: (_a = error == null ? void 0 : error.constructor) == null ? void 0 : _a.name,
2268
+ hasLastError: !!(error == null ? void 0 : error.lastError),
2269
+ lastErrorName: (_c = (_b = error == null ? void 0 : error.lastError) == null ? void 0 : _b.constructor) == null ? void 0 : _c.name,
2270
+ lastErrorMessage: (_d = error == null ? void 0 : error.lastError) == null ? void 0 : _d.message,
2271
+ context: error == null ? void 0 : error.context
2272
+ });
2183
2273
  c.status(500);
2184
2274
  c.json({
2185
2275
  code: "INTERNAL_SERVER_EXCEPTION",
@@ -2262,7 +2352,7 @@ var handler2 = (container) => (ev) => __async(null, null, function* () {
2262
2352
  const { entityRepository, mutualRepository, publishEvent: publishEvent2 } = container;
2263
2353
  yield Promise.allSettled(
2264
2354
  ev.Records.map((record) => __async(null, null, function* () {
2265
- var _a, _b, _c, _d;
2355
+ var _a, _b, _c, _d, _e;
2266
2356
  const errorContext = {};
2267
2357
  const body = parseSQSBusEvent(record.body);
2268
2358
  const { detail } = body;
@@ -2285,6 +2375,7 @@ var handler2 = (container) => (ev) => __async(null, null, function* () {
2285
2375
  );
2286
2376
  }
2287
2377
  const mutualDataProcessor = (_d = config.mutualDataProcessor) != null ? _d : (() => ({}));
2378
+ const mutualDataSchema = (_e = config.mutual) == null ? void 0 : _e.mutualDataSchema;
2288
2379
  yield mutualRepository.createMutualLock({
2289
2380
  byEntityType,
2290
2381
  byEntityId,
@@ -2320,6 +2411,20 @@ var handler2 = (container) => (ev) => __async(null, null, function* () {
2320
2411
  addedEntityIds,
2321
2412
  (id) => __async(null, null, function* () {
2322
2413
  const entity = yield entityRepository.getEntity(entityType, id);
2414
+ const processedMutualData = mutualDataProcessor(
2415
+ mutualIds,
2416
+ new Mutual(
2417
+ byEntityType,
2418
+ byEntityId,
2419
+ byEntity.data,
2420
+ entityType,
2421
+ id,
2422
+ entity.data,
2423
+ {}
2424
+ ),
2425
+ customContext
2426
+ );
2427
+ const parsedMutualData = mutualDataSchema ? mutualDataSchema.parse(processedMutualData) : processedMutualData;
2323
2428
  yield mutualRepository.createMutual(
2324
2429
  byEntityType,
2325
2430
  byEntityId,
@@ -2327,19 +2432,7 @@ var handler2 = (container) => (ev) => __async(null, null, function* () {
2327
2432
  entityType,
2328
2433
  id,
2329
2434
  entity.data,
2330
- mutualDataProcessor(
2331
- mutualIds,
2332
- new Mutual(
2333
- byEntityType,
2334
- byEntityId,
2335
- byEntity.data,
2336
- entityType,
2337
- id,
2338
- entity.data,
2339
- {}
2340
- ),
2341
- customContext
2342
- ),
2435
+ parsedMutualData,
2343
2436
  {
2344
2437
  ConditionExpression: "attribute_not_exists(#mutualUpdatedAt) OR #mutualUpdatedAt < :publishedAt",
2345
2438
  ExpressionAttributeNames: {
@@ -2376,25 +2469,27 @@ var handler2 = (container) => (ev) => __async(null, null, function* () {
2376
2469
  const updateEntities = yield processEntities(
2377
2470
  toUpdateEntityIds,
2378
2471
  (id) => __async(null, null, function* () {
2472
+ const processedMutualData = mutualDataProcessor(
2473
+ mutualIds,
2474
+ new Mutual(
2475
+ byEntityType,
2476
+ byEntityId,
2477
+ byEntity.data,
2478
+ entityType,
2479
+ id,
2480
+ {},
2481
+ {}
2482
+ ),
2483
+ customContext
2484
+ );
2485
+ const parsedMutualData = mutualDataSchema ? mutualDataSchema.parse(processedMutualData) : processedMutualData;
2379
2486
  yield mutualRepository.updateMutual(
2380
2487
  byEntityType,
2381
2488
  byEntityId,
2382
2489
  entityType,
2383
2490
  id,
2384
2491
  {
2385
- mutualData: mutualDataProcessor(
2386
- mutualIds,
2387
- new Mutual(
2388
- byEntityType,
2389
- byEntityId,
2390
- byEntity.data,
2391
- entityType,
2392
- id,
2393
- {},
2394
- {}
2395
- ),
2396
- customContext
2397
- ),
2492
+ mutualData: parsedMutualData,
2398
2493
  mutualUpdatedAt: publishedAt
2399
2494
  },
2400
2495
  {
@@ -7846,7 +7941,8 @@ var EntityService = class {
7846
7941
  // services/mutual.service.ts
7847
7942
  import { ulid as ulid3 } from "ulid";
7848
7943
  var MutualService = class {
7849
- constructor(entityRepository, mutualRepository, publishEvent2, ddbUtils, entityServiceLifeCycle) {
7944
+ constructor(EntityConfig, entityRepository, mutualRepository, publishEvent2, ddbUtils, entityServiceLifeCycle) {
7945
+ this.EntityConfig = EntityConfig;
7850
7946
  this.entityRepository = entityRepository;
7851
7947
  this.mutualRepository = mutualRepository;
7852
7948
  this.publishEvent = publishEvent2;
@@ -7861,6 +7957,7 @@ var MutualService = class {
7861
7957
  accountId,
7862
7958
  options = {}
7863
7959
  }) {
7960
+ var _a;
7864
7961
  const {
7865
7962
  ensureEntityStrongConsistentWrite = false,
7866
7963
  asEntity,
@@ -7881,20 +7978,37 @@ var MutualService = class {
7881
7978
  options
7882
7979
  }
7883
7980
  };
7884
- const schema = external_exports.record(external_exports.string(), external_exports.any());
7981
+ console.log("[MONORISE_DEBUG] createMutual service start:", {
7982
+ byEntityType,
7983
+ byEntityId,
7984
+ entityType,
7985
+ entityId,
7986
+ mutualPayload,
7987
+ options
7988
+ });
7989
+ const schema = (_a = this.getMutualDataSchema(byEntityType, entityType)) != null ? _a : external_exports.record(external_exports.string(), external_exports.any());
7990
+ console.log("[MONORISE_DEBUG] createMutual schema resolved");
7885
7991
  const parsedMutualPayload = schema.parse(mutualPayload);
7992
+ console.log("[MONORISE_DEBUG] createMutual payload parsed:", parsedMutualPayload);
7993
+ console.log("[MONORISE_DEBUG] createMutual fetching entities...");
7886
7994
  const [{ data: byEntityData }, { data: entityData }] = yield Promise.all([
7887
7995
  this.entityRepository.getEntity(byEntityType, byEntityId),
7888
7996
  this.entityRepository.getEntity(entityType, entityId)
7889
7997
  ]);
7998
+ console.log("[MONORISE_DEBUG] createMutual entities fetched:", {
7999
+ hasByEntityData: !!byEntityData,
8000
+ hasEntityData: !!entityData
8001
+ });
7890
8002
  errorContext.byEntityData = byEntityData;
7891
8003
  errorContext.entityData = entityData;
8004
+ console.log("[MONORISE_DEBUG] createMutual checking mutual exist...");
7892
8005
  yield this.mutualRepository.checkMutualExist(
7893
8006
  byEntityType,
7894
8007
  byEntityId,
7895
8008
  entityType,
7896
8009
  entityId
7897
8010
  );
8011
+ console.log("[MONORISE_DEBUG] createMutual mutual does not exist (ok)");
7898
8012
  const currentDatetime = createAndUpdateDatetime || /* @__PURE__ */ new Date();
7899
8013
  const mutual = new Mutual(
7900
8014
  byEntityType,
@@ -7909,6 +8023,9 @@ var MutualService = class {
7909
8023
  currentDatetime,
7910
8024
  currentDatetime
7911
8025
  );
8026
+ console.log("[MONORISE_DEBUG] createMutual mutual object created:", {
8027
+ mutualId: mutual.mutualId
8028
+ });
7912
8029
  const mutualTransactions = skipMutualCreation ? [] : this.mutualRepository.createMutualTransactItems(mutual, {
7913
8030
  ConditionExpression,
7914
8031
  ExpressionAttributeNames,
@@ -7932,9 +8049,13 @@ var MutualService = class {
7932
8049
  }
7933
8050
  const createTransactItems = [...mutualTransactions, ...entityTransactions];
7934
8051
  errorContext.createTransactItems = createTransactItems;
8052
+ console.log("[MONORISE_DEBUG] createMutual executing transaction:", {
8053
+ transactItemCount: createTransactItems.length
8054
+ });
7935
8055
  yield this.ddbUtils.executeTransactWrite({
7936
8056
  TransactItems: createTransactItems
7937
8057
  });
8058
+ console.log("[MONORISE_DEBUG] createMutual transaction succeeded");
7938
8059
  if (asEntity && entity && ensureEntityStrongConsistentWrite) {
7939
8060
  yield this.entityServiceLifeCycle.afterCreateEntityHook(
7940
8061
  entity,
@@ -7973,6 +8094,7 @@ var MutualService = class {
7973
8094
  })
7974
8095
  ];
7975
8096
  yield Promise.all(eventPromises);
8097
+ console.log("[MONORISE_DEBUG] createMutual service complete");
7976
8098
  return { mutual, eventPayload };
7977
8099
  });
7978
8100
  this.updateMutual = (_0) => __async(this, [_0], function* ({
@@ -7984,8 +8106,20 @@ var MutualService = class {
7984
8106
  accountId,
7985
8107
  options
7986
8108
  }) {
7987
- const schema = external_exports.record(external_exports.string(), external_exports.any());
8109
+ var _a;
8110
+ console.log("[MONORISE_DEBUG] updateMutual service start:", {
8111
+ byEntityType,
8112
+ byEntityId,
8113
+ entityType,
8114
+ entityId,
8115
+ mutualPayload,
8116
+ options
8117
+ });
8118
+ const schema = (_a = this.getMutualDataSchema(byEntityType, entityType)) != null ? _a : external_exports.record(external_exports.string(), external_exports.any());
8119
+ console.log("[MONORISE_DEBUG] updateMutual schema resolved");
7988
8120
  const parsedMutualPayload = schema.parse(mutualPayload);
8121
+ console.log("[MONORISE_DEBUG] updateMutual payload parsed:", parsedMutualPayload);
8122
+ console.log("[MONORISE_DEBUG] updateMutual calling repository...");
7989
8123
  const mutual = yield this.mutualRepository.updateMutual(
7990
8124
  byEntityType,
7991
8125
  byEntityId,
@@ -7994,6 +8128,10 @@ var MutualService = class {
7994
8128
  { mutualData: parsedMutualPayload },
7995
8129
  options
7996
8130
  );
8131
+ console.log("[MONORISE_DEBUG] updateMutual repository result:", {
8132
+ hasMutual: !!mutual,
8133
+ mutualId: mutual == null ? void 0 : mutual.mutualId
8134
+ });
7997
8135
  yield this.publishEvent({
7998
8136
  event: EVENT.CORE.MUTUAL_UPDATED(byEntityType, entityType),
7999
8137
  payload: {
@@ -8005,6 +8143,7 @@ var MutualService = class {
8005
8143
  updatedByAccountId: accountId
8006
8144
  }
8007
8145
  });
8146
+ console.log("[MONORISE_DEBUG] updateMutual service complete");
8008
8147
  return mutual;
8009
8148
  });
8010
8149
  this.deleteMutual = (_0) => __async(this, [_0], function* ({
@@ -8033,6 +8172,22 @@ var MutualService = class {
8033
8172
  return mutual;
8034
8173
  });
8035
8174
  }
8175
+ getMutualDataSchema(byEntityType, entityType) {
8176
+ var _a, _b, _c;
8177
+ for (const [from, to] of [
8178
+ [byEntityType, entityType],
8179
+ [entityType, byEntityType]
8180
+ ]) {
8181
+ const mutualFields = (_b = (_a = this.EntityConfig[from]) == null ? void 0 : _a.mutual) == null ? void 0 : _b.mutualFields;
8182
+ if (!mutualFields) continue;
8183
+ for (const config of Object.values(mutualFields)) {
8184
+ if (config.entityType === to && ((_c = config.mutual) == null ? void 0 : _c.mutualDataSchema)) {
8185
+ return config.mutual.mutualDataSchema;
8186
+ }
8187
+ }
8188
+ }
8189
+ return void 0;
8190
+ }
8036
8191
  };
8037
8192
 
8038
8193
  // controllers/tag/list-tags.controller.ts
@@ -8192,6 +8347,7 @@ var DependencyContainer = class {
8192
8347
  get mutualService() {
8193
8348
  return this.createCachedInstance(
8194
8349
  MutualService,
8350
+ this.config.EntityConfig,
8195
8351
  this.entityRepository,
8196
8352
  this.mutualRepository,
8197
8353
  this.publishEvent,