@monorise/core 5.0.0-dev.2 → 5.0.0-dev.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.d.ts +3 -53
- package/dist/index.js +194 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Entity as Entity$2, EntitySchemaMap, createEntityConfig, WhereConditions } from '@monorise/base';
|
|
1
|
+
import { Entity as Entity$2, EntitySchemaMap, createEntityConfig, WhereConditions, TransactionOperation, TransactionResult } from '@monorise/base';
|
|
2
|
+
export { transactional } from '@monorise/base';
|
|
2
3
|
import * as hono from 'hono';
|
|
3
4
|
import { Hono } from 'hono';
|
|
4
5
|
import { DynamoDB, TransactWriteItemsInput, AttributeValue, TransactWriteItem, UpdateItemCommandInput } from '@aws-sdk/client-dynamodb';
|
|
@@ -4724,44 +4725,6 @@ declare class ListTagsController {
|
|
|
4724
4725
|
}, hono_utils_http_status.ContentfulStatusCode, "json">>;
|
|
4725
4726
|
}
|
|
4726
4727
|
|
|
4727
|
-
type TransactionCreateEntity<T extends Entity$2 = Entity$2> = {
|
|
4728
|
-
operation: 'createEntity';
|
|
4729
|
-
entityType: T;
|
|
4730
|
-
entityId?: string;
|
|
4731
|
-
payload: EntitySchemaMap[T];
|
|
4732
|
-
};
|
|
4733
|
-
type TransactionUpdateEntity<T extends Entity$2 = Entity$2> = {
|
|
4734
|
-
operation: 'updateEntity';
|
|
4735
|
-
entityType: T;
|
|
4736
|
-
entityId: string;
|
|
4737
|
-
payload: Partial<EntitySchemaMap[T]>;
|
|
4738
|
-
accountId?: string;
|
|
4739
|
-
condition?: string;
|
|
4740
|
-
};
|
|
4741
|
-
type TransactionAdjustEntity<T extends Entity$2 = Entity$2> = {
|
|
4742
|
-
operation: 'adjustEntity';
|
|
4743
|
-
entityType: T;
|
|
4744
|
-
entityId: string;
|
|
4745
|
-
adjustments: Record<string, number>;
|
|
4746
|
-
accountId?: string;
|
|
4747
|
-
condition?: string;
|
|
4748
|
-
};
|
|
4749
|
-
type TransactionDeleteEntity<T extends Entity$2 = Entity$2> = {
|
|
4750
|
-
operation: 'deleteEntity';
|
|
4751
|
-
entityType: T;
|
|
4752
|
-
entityId: string;
|
|
4753
|
-
};
|
|
4754
|
-
type TransactionOperation = TransactionCreateEntity | TransactionUpdateEntity | TransactionAdjustEntity | TransactionDeleteEntity;
|
|
4755
|
-
type TransactionResultEntry = {
|
|
4756
|
-
operation: string;
|
|
4757
|
-
entityType: Entity$2;
|
|
4758
|
-
entityId: string;
|
|
4759
|
-
data?: Record<string, unknown>;
|
|
4760
|
-
};
|
|
4761
|
-
type TransactionResult = {
|
|
4762
|
-
results: TransactionResultEntry[];
|
|
4763
|
-
};
|
|
4764
|
-
|
|
4765
4728
|
declare class TransactionService {
|
|
4766
4729
|
private EntityConfig;
|
|
4767
4730
|
private EmailAuthEnabledEntities;
|
|
@@ -4943,19 +4906,6 @@ declare const $default: (container: DependencyContainer) => (event: APIGatewayPr
|
|
|
4943
4906
|
*/
|
|
4944
4907
|
declare const broadcast: (container: DependencyContainer) => (event: DynamoDBStreamEvent) => Promise<void>;
|
|
4945
4908
|
|
|
4946
|
-
declare const transactional: {
|
|
4947
|
-
createEntity: <T extends Entity$2>(entityType: T, payload: EntitySchemaMap[T] & {
|
|
4948
|
-
entityId?: string;
|
|
4949
|
-
}) => TransactionCreateEntity<T>;
|
|
4950
|
-
updateEntity: <T extends Entity$2>(entityType: T, entityId: string, payload: Partial<EntitySchemaMap[T]> & {
|
|
4951
|
-
$condition?: string;
|
|
4952
|
-
}) => TransactionUpdateEntity<T>;
|
|
4953
|
-
adjustEntity: <T extends Entity$2>(entityType: T, entityId: string, adjustments: Record<string, number> & {
|
|
4954
|
-
$condition?: string;
|
|
4955
|
-
}) => TransactionAdjustEntity<T>;
|
|
4956
|
-
deleteEntity: <T extends Entity$2>(entityType: T, entityId: string) => TransactionDeleteEntity<T>;
|
|
4957
|
-
};
|
|
4958
|
-
|
|
4959
4909
|
declare class CoreFactory {
|
|
4960
4910
|
private config;
|
|
4961
4911
|
setupCommonRoutes: ReturnType<typeof setupCommonRoutes>;
|
|
@@ -4977,4 +4927,4 @@ declare class CoreFactory {
|
|
|
4977
4927
|
});
|
|
4978
4928
|
}
|
|
4979
4929
|
|
|
4980
|
-
export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, StandardError, StandardErrorCode, TagRepository, TransactionService, WebSocketRepository, appHandler, handler$4 as createEntityProcessor, CoreFactory as default, handler$3 as mutualProcessor, handler$2 as prejoinProcessor, handler$1 as replicationProcessor, setupCommonRoutes, handler as tagProcessor,
|
|
4930
|
+
export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, StandardError, StandardErrorCode, TagRepository, TransactionService, WebSocketRepository, appHandler, handler$4 as createEntityProcessor, CoreFactory as default, handler$3 as mutualProcessor, handler$2 as prejoinProcessor, handler$1 as replicationProcessor, setupCommonRoutes, handler as tagProcessor, broadcast as wsBroadcast, connect as wsConnect, $default as wsDefault, disconnect as wsDisconnect };
|
package/dist/index.js
CHANGED
|
@@ -1075,7 +1075,14 @@ var MutualRepository = class extends Repository {
|
|
|
1075
1075
|
}
|
|
1076
1076
|
getMutual(byEntityType, byEntityId, entityType, entityId, opts) {
|
|
1077
1077
|
return __async(this, null, function* () {
|
|
1078
|
-
var _a, _b;
|
|
1078
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1079
|
+
console.log("[MONORISE_DEBUG] getMutual start:", {
|
|
1080
|
+
byEntityType,
|
|
1081
|
+
byEntityId,
|
|
1082
|
+
entityType,
|
|
1083
|
+
entityId,
|
|
1084
|
+
opts
|
|
1085
|
+
});
|
|
1079
1086
|
const mutual = new Mutual(
|
|
1080
1087
|
byEntityType,
|
|
1081
1088
|
byEntityId,
|
|
@@ -1085,6 +1092,11 @@ var MutualRepository = class extends Repository {
|
|
|
1085
1092
|
{},
|
|
1086
1093
|
{}
|
|
1087
1094
|
);
|
|
1095
|
+
console.log("[MONORISE_DEBUG] getMutual querying:", {
|
|
1096
|
+
byFullEntityId: mutual.byFullEntityId,
|
|
1097
|
+
fullEntityId: mutual.fullEntityId,
|
|
1098
|
+
tableName: this.TABLE_NAME
|
|
1099
|
+
});
|
|
1088
1100
|
const resp = yield this.dynamodbClient.query({
|
|
1089
1101
|
TableName: this.TABLE_NAME,
|
|
1090
1102
|
KeyConditionExpression: "#PK = :PK and begins_with(#SK, :SK)",
|
|
@@ -1101,9 +1113,14 @@ var MutualRepository = class extends Repository {
|
|
|
1101
1113
|
},
|
|
1102
1114
|
Limit: 1
|
|
1103
1115
|
});
|
|
1116
|
+
console.log("[MONORISE_DEBUG] getMutual query result:", {
|
|
1117
|
+
hasItems: !!((_a = resp.Items) == null ? void 0 : _a.length),
|
|
1118
|
+
itemCount: (_c = (_b = resp.Items) == null ? void 0 : _b.length) != null ? _c : 0,
|
|
1119
|
+
hasLastEvaluatedKey: !!resp.LastEvaluatedKey
|
|
1120
|
+
});
|
|
1104
1121
|
let mutualMetadata = null;
|
|
1105
1122
|
if (opts == null ? void 0 : opts.isFromMetadata) {
|
|
1106
|
-
const tempMutual = Mutual.fromItem((
|
|
1123
|
+
const tempMutual = Mutual.fromItem((_d = resp.Items) == null ? void 0 : _d[0]);
|
|
1107
1124
|
const respMetadataMutual = yield this.dynamodbClient.getItem({
|
|
1108
1125
|
TableName: this.TABLE_NAME,
|
|
1109
1126
|
Key: tempMutual.mainKeys(),
|
|
@@ -1111,12 +1128,28 @@ var MutualRepository = class extends Repository {
|
|
|
1111
1128
|
});
|
|
1112
1129
|
mutualMetadata = Mutual.fromItem(respMetadataMutual.Item);
|
|
1113
1130
|
}
|
|
1114
|
-
|
|
1131
|
+
console.log("[MONORISE_DEBUG] getMutual fromItem:", {
|
|
1132
|
+
hasMutualMetadata: !!mutualMetadata,
|
|
1133
|
+
hasFirstItem: !!((_e = resp.Items) == null ? void 0 : _e[0])
|
|
1134
|
+
});
|
|
1135
|
+
const result = mutualMetadata || Mutual.fromItem((_f = resp.Items) == null ? void 0 : _f[0]);
|
|
1136
|
+
console.log("[MONORISE_DEBUG] getMutual complete:", {
|
|
1137
|
+
mutualId: result.mutualId,
|
|
1138
|
+
byEntityType: result.byEntityType,
|
|
1139
|
+
entityType: result.entityType
|
|
1140
|
+
});
|
|
1141
|
+
return result;
|
|
1115
1142
|
});
|
|
1116
1143
|
}
|
|
1117
1144
|
checkMutualExist(byEntityType, byEntityId, entityType, entityId) {
|
|
1118
1145
|
return __async(this, null, function* () {
|
|
1119
|
-
var _a;
|
|
1146
|
+
var _a, _b;
|
|
1147
|
+
console.log("[MONORISE_DEBUG] checkMutualExist:", {
|
|
1148
|
+
byEntityType,
|
|
1149
|
+
byEntityId,
|
|
1150
|
+
entityType,
|
|
1151
|
+
entityId
|
|
1152
|
+
});
|
|
1120
1153
|
const mutual = new Mutual(
|
|
1121
1154
|
byEntityType,
|
|
1122
1155
|
byEntityId,
|
|
@@ -1131,7 +1164,11 @@ var MutualRepository = class extends Repository {
|
|
|
1131
1164
|
Key: mutual.subKeys(),
|
|
1132
1165
|
ProjectionExpression: "PK, SK, expiresAt"
|
|
1133
1166
|
});
|
|
1134
|
-
|
|
1167
|
+
console.log("[MONORISE_DEBUG] checkMutualExist result:", {
|
|
1168
|
+
hasItem: !!resp.Item,
|
|
1169
|
+
hasExpiresAt: !!((_a = resp.Item) == null ? void 0 : _a.expiresAt)
|
|
1170
|
+
});
|
|
1171
|
+
if (resp.Item && !((_b = resp.Item) == null ? void 0 : _b.expiresAt)) {
|
|
1135
1172
|
throw new StandardError(
|
|
1136
1173
|
StandardErrorCode.MUTUAL_EXISTS,
|
|
1137
1174
|
"Entities are already linked"
|
|
@@ -1141,6 +1178,14 @@ var MutualRepository = class extends Repository {
|
|
|
1141
1178
|
});
|
|
1142
1179
|
}
|
|
1143
1180
|
createMutualTransactItems(mutual, opts) {
|
|
1181
|
+
console.log("[MONORISE_DEBUG] createMutualTransactItems:", {
|
|
1182
|
+
mutualId: mutual.mutualId,
|
|
1183
|
+
byEntityType: mutual.byEntityType,
|
|
1184
|
+
byEntityId: mutual.byEntityId,
|
|
1185
|
+
entityType: mutual.entityType,
|
|
1186
|
+
entityId: mutual.entityId,
|
|
1187
|
+
hasOpts: !!opts
|
|
1188
|
+
});
|
|
1144
1189
|
const TransactItems = [
|
|
1145
1190
|
{
|
|
1146
1191
|
Put: {
|
|
@@ -1215,10 +1260,19 @@ var MutualRepository = class extends Repository {
|
|
|
1215
1260
|
}
|
|
1216
1261
|
updateMutual(byEntityType, byEntityId, entityType, entityId, toUpdate, opts) {
|
|
1217
1262
|
return __async(this, null, function* () {
|
|
1218
|
-
var _a;
|
|
1263
|
+
var _a, _b;
|
|
1264
|
+
console.log("[MONORISE_DEBUG] updateMutual repository start:", {
|
|
1265
|
+
byEntityType,
|
|
1266
|
+
byEntityId,
|
|
1267
|
+
entityType,
|
|
1268
|
+
entityId,
|
|
1269
|
+
toUpdateKeys: Object.keys(toUpdate),
|
|
1270
|
+
opts
|
|
1271
|
+
});
|
|
1219
1272
|
const returnUpdatedValue = (_a = opts == null ? void 0 : opts.returnUpdatedValue) != null ? _a : false;
|
|
1220
1273
|
const errorContext = {};
|
|
1221
1274
|
try {
|
|
1275
|
+
console.log("[MONORISE_DEBUG] updateMutual fetching mutual...");
|
|
1222
1276
|
const mutual = yield this.getMutual(
|
|
1223
1277
|
byEntityType,
|
|
1224
1278
|
byEntityId,
|
|
@@ -1226,6 +1280,12 @@ var MutualRepository = class extends Repository {
|
|
|
1226
1280
|
entityId,
|
|
1227
1281
|
{ ProjectionExpression: PROJECTION_EXPRESSION.NO_DATA }
|
|
1228
1282
|
);
|
|
1283
|
+
console.log("[MONORISE_DEBUG] updateMutual mutual found:", {
|
|
1284
|
+
mutualId: mutual.mutualId,
|
|
1285
|
+
mainPk: mutual.mainPk,
|
|
1286
|
+
byFullEntityId: mutual.byFullEntityId,
|
|
1287
|
+
fullEntityId: mutual.fullEntityId
|
|
1288
|
+
});
|
|
1229
1289
|
const currentDatetime = (/* @__PURE__ */ new Date()).toISOString();
|
|
1230
1290
|
const toUpdateExpressions = this.toUpdate(
|
|
1231
1291
|
__spreadValues({
|
|
@@ -1233,6 +1293,11 @@ var MutualRepository = class extends Repository {
|
|
|
1233
1293
|
}, toUpdate),
|
|
1234
1294
|
{ maxLevel: opts == null ? void 0 : opts.maxObjectUpdateLevel }
|
|
1235
1295
|
);
|
|
1296
|
+
console.log("[MONORISE_DEBUG] updateMutual update expression:", {
|
|
1297
|
+
UpdateExpression: toUpdateExpressions.UpdateExpression,
|
|
1298
|
+
ExpressionAttributeNames: toUpdateExpressions.ExpressionAttributeNames,
|
|
1299
|
+
hasExpressionAttributeValues: !!toUpdateExpressions.ExpressionAttributeValues
|
|
1300
|
+
});
|
|
1236
1301
|
const updateExpression = {
|
|
1237
1302
|
ConditionExpression: (opts == null ? void 0 : opts.ConditionExpression) || "attribute_exists(PK)",
|
|
1238
1303
|
UpdateExpression: toUpdateExpressions.UpdateExpression,
|
|
@@ -1266,18 +1331,33 @@ var MutualRepository = class extends Repository {
|
|
|
1266
1331
|
}
|
|
1267
1332
|
];
|
|
1268
1333
|
errorContext.TransactItems = TransactItems;
|
|
1334
|
+
console.log("[MONORISE_DEBUG] updateMutual transact items prepared:", {
|
|
1335
|
+
itemCount: TransactItems.length,
|
|
1336
|
+
tableName: this.TABLE_NAME
|
|
1337
|
+
});
|
|
1338
|
+
console.log("[MONORISE_DEBUG] updateMutual executing transaction...");
|
|
1269
1339
|
yield this.ddbUtils.executeTransactWrite({ TransactItems });
|
|
1340
|
+
console.log("[MONORISE_DEBUG] updateMutual transaction succeeded");
|
|
1270
1341
|
if (!returnUpdatedValue) {
|
|
1342
|
+
console.log("[MONORISE_DEBUG] updateMutual returning (no value)");
|
|
1271
1343
|
return;
|
|
1272
1344
|
}
|
|
1345
|
+
console.log("[MONORISE_DEBUG] updateMutual fetching updated mutual...");
|
|
1273
1346
|
const updatedMutual = yield this.getMutual(
|
|
1274
1347
|
byEntityType,
|
|
1275
1348
|
byEntityId,
|
|
1276
1349
|
entityType,
|
|
1277
1350
|
entityId
|
|
1278
1351
|
);
|
|
1352
|
+
console.log("[MONORISE_DEBUG] updateMutual repository complete");
|
|
1279
1353
|
return updatedMutual;
|
|
1280
1354
|
} catch (err) {
|
|
1355
|
+
console.error("[MONORISE_DEBUG] updateMutual repository error:", {
|
|
1356
|
+
errorName: (_b = err == null ? void 0 : err.constructor) == null ? void 0 : _b.name,
|
|
1357
|
+
errorMessage: err == null ? void 0 : err.message,
|
|
1358
|
+
errorCode: err == null ? void 0 : err.code,
|
|
1359
|
+
isStandardError: err instanceof StandardError
|
|
1360
|
+
});
|
|
1281
1361
|
if (err instanceof StandardError && err.code === StandardErrorCode.CONDITIONAL_CHECK_FAILED) {
|
|
1282
1362
|
throw new StandardError(
|
|
1283
1363
|
StandardErrorCode.MUTUAL_NOT_FOUND,
|
|
@@ -2215,6 +2295,7 @@ var getDependencies = () => {
|
|
|
2215
2295
|
// middlewares/general-error-handler.ts
|
|
2216
2296
|
var factory2 = createFactory2();
|
|
2217
2297
|
var generalErrorHandler = (dependencies = getDependencies()) => factory2.createMiddleware((c) => __async(null, null, function* () {
|
|
2298
|
+
var _a, _b, _c, _d;
|
|
2218
2299
|
if (c.error) {
|
|
2219
2300
|
const { nanoid: nanoid2, publishErrorEvent: publishErrorEvent2 } = dependencies;
|
|
2220
2301
|
const errorId = nanoid2();
|
|
@@ -2227,12 +2308,21 @@ var generalErrorHandler = (dependencies = getDependencies()) => factory2.createM
|
|
|
2227
2308
|
body,
|
|
2228
2309
|
error: c.error
|
|
2229
2310
|
});
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2311
|
+
const error = c.error;
|
|
2312
|
+
console.warn("[MONORISE_DEBUG] INTERNAL_SERVER_EXCEPTION:", {
|
|
2313
|
+
errorId,
|
|
2314
|
+
method: c.req.method,
|
|
2315
|
+
path: c.req.path,
|
|
2316
|
+
errorName: error == null ? void 0 : error.name,
|
|
2317
|
+
errorMessage: error == null ? void 0 : error.message,
|
|
2318
|
+
errorCode: error == null ? void 0 : error.code,
|
|
2319
|
+
errorStack: error == null ? void 0 : error.stack,
|
|
2320
|
+
errorConstructor: (_a = error == null ? void 0 : error.constructor) == null ? void 0 : _a.name,
|
|
2321
|
+
hasLastError: !!(error == null ? void 0 : error.lastError),
|
|
2322
|
+
lastErrorName: (_c = (_b = error == null ? void 0 : error.lastError) == null ? void 0 : _b.constructor) == null ? void 0 : _c.name,
|
|
2323
|
+
lastErrorMessage: (_d = error == null ? void 0 : error.lastError) == null ? void 0 : _d.message,
|
|
2324
|
+
context: error == null ? void 0 : error.context
|
|
2325
|
+
});
|
|
2236
2326
|
c.status(500);
|
|
2237
2327
|
c.json({
|
|
2238
2328
|
code: "INTERNAL_SERVER_EXCEPTION",
|
|
@@ -7930,6 +8020,7 @@ var CreateMutualController = class {
|
|
|
7930
8020
|
constructor(mutualService) {
|
|
7931
8021
|
this.mutualService = mutualService;
|
|
7932
8022
|
this.controller = createMiddleware11((c) => __async(this, null, function* () {
|
|
8023
|
+
var _a;
|
|
7933
8024
|
const accountId = c.req.header("account-id");
|
|
7934
8025
|
const { byEntityType, byEntityId, entityType, entityId } = c.req.param();
|
|
7935
8026
|
const asEntity = c.req.query("asEntity");
|
|
@@ -7948,7 +8039,7 @@ var CreateMutualController = class {
|
|
|
7948
8039
|
});
|
|
7949
8040
|
return c.json(mutual);
|
|
7950
8041
|
} catch (err) {
|
|
7951
|
-
if (err
|
|
8042
|
+
if (((_a = err == null ? void 0 : err.constructor) == null ? void 0 : _a.name) === "ZodError") {
|
|
7952
8043
|
c.status(httpStatus11.BAD_REQUEST);
|
|
7953
8044
|
return c.json({
|
|
7954
8045
|
code: "API_VALIDATION_ERROR",
|
|
@@ -7956,15 +8047,15 @@ var CreateMutualController = class {
|
|
|
7956
8047
|
details: err.flatten()
|
|
7957
8048
|
});
|
|
7958
8049
|
}
|
|
7959
|
-
if (err instanceof StandardError
|
|
7960
|
-
c.status(httpStatus11.BAD_REQUEST);
|
|
7961
|
-
return c.json(__spreadValues({}, err.toJSON()));
|
|
7962
|
-
}
|
|
7963
|
-
if (err instanceof StandardError && err.code === StandardErrorCode.ENTITY_IS_UNDEFINED) {
|
|
8050
|
+
if (err instanceof StandardError) {
|
|
7964
8051
|
c.status(httpStatus11.BAD_REQUEST);
|
|
7965
8052
|
return c.json(__spreadValues({}, err.toJSON()));
|
|
7966
8053
|
}
|
|
7967
|
-
|
|
8054
|
+
c.status(httpStatus11.INTERNAL_SERVER_ERROR);
|
|
8055
|
+
return c.json({
|
|
8056
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
8057
|
+
message: (err == null ? void 0 : err.message) || "An unexpected error occurred"
|
|
8058
|
+
});
|
|
7968
8059
|
}
|
|
7969
8060
|
}));
|
|
7970
8061
|
}
|
|
@@ -8098,6 +8189,7 @@ var UpdateMutualController = class {
|
|
|
8098
8189
|
constructor(mutualService) {
|
|
8099
8190
|
this.mutualService = mutualService;
|
|
8100
8191
|
this.controller = createMiddleware15((c) => __async(this, null, function* () {
|
|
8192
|
+
var _a;
|
|
8101
8193
|
const accountId = c.req.header("account-id");
|
|
8102
8194
|
const { byEntityType, byEntityId, entityType, entityId } = c.req.param();
|
|
8103
8195
|
const body = yield c.req.json();
|
|
@@ -8115,7 +8207,7 @@ var UpdateMutualController = class {
|
|
|
8115
8207
|
});
|
|
8116
8208
|
return c.json(mutual);
|
|
8117
8209
|
} catch (err) {
|
|
8118
|
-
if (err
|
|
8210
|
+
if (((_a = err == null ? void 0 : err.constructor) == null ? void 0 : _a.name) === "ZodError") {
|
|
8119
8211
|
c.status(httpStatus14.BAD_REQUEST);
|
|
8120
8212
|
return c.json({
|
|
8121
8213
|
code: "API_VALIDATION_ERROR",
|
|
@@ -8123,11 +8215,15 @@ var UpdateMutualController = class {
|
|
|
8123
8215
|
details: err.flatten()
|
|
8124
8216
|
});
|
|
8125
8217
|
}
|
|
8126
|
-
if (err instanceof StandardError
|
|
8218
|
+
if (err instanceof StandardError) {
|
|
8127
8219
|
c.status(httpStatus14.BAD_REQUEST);
|
|
8128
8220
|
return c.json(__spreadValues({}, err.toJSON()));
|
|
8129
8221
|
}
|
|
8130
|
-
|
|
8222
|
+
c.status(httpStatus14.INTERNAL_SERVER_ERROR);
|
|
8223
|
+
return c.json({
|
|
8224
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
8225
|
+
message: (err == null ? void 0 : err.message) || "An unexpected error occurred"
|
|
8226
|
+
});
|
|
8131
8227
|
}
|
|
8132
8228
|
}));
|
|
8133
8229
|
}
|
|
@@ -8552,20 +8648,37 @@ var MutualService = class {
|
|
|
8552
8648
|
options
|
|
8553
8649
|
}
|
|
8554
8650
|
};
|
|
8651
|
+
console.log("[MONORISE_DEBUG] createMutual service start:", {
|
|
8652
|
+
byEntityType,
|
|
8653
|
+
byEntityId,
|
|
8654
|
+
entityType,
|
|
8655
|
+
entityId,
|
|
8656
|
+
mutualPayload,
|
|
8657
|
+
options
|
|
8658
|
+
});
|
|
8555
8659
|
const schema = (_a = this.getMutualDataSchema(byEntityType, entityType)) != null ? _a : external_exports.record(external_exports.string(), external_exports.any());
|
|
8660
|
+
console.log("[MONORISE_DEBUG] createMutual schema resolved");
|
|
8556
8661
|
const parsedMutualPayload = schema.parse(mutualPayload);
|
|
8662
|
+
console.log("[MONORISE_DEBUG] createMutual payload parsed:", parsedMutualPayload);
|
|
8663
|
+
console.log("[MONORISE_DEBUG] createMutual fetching entities...");
|
|
8557
8664
|
const [{ data: byEntityData }, { data: entityData }] = yield Promise.all([
|
|
8558
8665
|
this.entityRepository.getEntity(byEntityType, byEntityId),
|
|
8559
8666
|
this.entityRepository.getEntity(entityType, entityId)
|
|
8560
8667
|
]);
|
|
8668
|
+
console.log("[MONORISE_DEBUG] createMutual entities fetched:", {
|
|
8669
|
+
hasByEntityData: !!byEntityData,
|
|
8670
|
+
hasEntityData: !!entityData
|
|
8671
|
+
});
|
|
8561
8672
|
errorContext.byEntityData = byEntityData;
|
|
8562
8673
|
errorContext.entityData = entityData;
|
|
8674
|
+
console.log("[MONORISE_DEBUG] createMutual checking mutual exist...");
|
|
8563
8675
|
yield this.mutualRepository.checkMutualExist(
|
|
8564
8676
|
byEntityType,
|
|
8565
8677
|
byEntityId,
|
|
8566
8678
|
entityType,
|
|
8567
8679
|
entityId
|
|
8568
8680
|
);
|
|
8681
|
+
console.log("[MONORISE_DEBUG] createMutual mutual does not exist (ok)");
|
|
8569
8682
|
const currentDatetime = createAndUpdateDatetime || /* @__PURE__ */ new Date();
|
|
8570
8683
|
const mutual = new Mutual(
|
|
8571
8684
|
byEntityType,
|
|
@@ -8580,6 +8693,9 @@ var MutualService = class {
|
|
|
8580
8693
|
currentDatetime,
|
|
8581
8694
|
currentDatetime
|
|
8582
8695
|
);
|
|
8696
|
+
console.log("[MONORISE_DEBUG] createMutual mutual object created:", {
|
|
8697
|
+
mutualId: mutual.mutualId
|
|
8698
|
+
});
|
|
8583
8699
|
const mutualTransactions = skipMutualCreation ? [] : this.mutualRepository.createMutualTransactItems(mutual, {
|
|
8584
8700
|
ConditionExpression,
|
|
8585
8701
|
ExpressionAttributeNames,
|
|
@@ -8603,9 +8719,13 @@ var MutualService = class {
|
|
|
8603
8719
|
}
|
|
8604
8720
|
const createTransactItems = [...mutualTransactions, ...entityTransactions];
|
|
8605
8721
|
errorContext.createTransactItems = createTransactItems;
|
|
8722
|
+
console.log("[MONORISE_DEBUG] createMutual executing transaction:", {
|
|
8723
|
+
transactItemCount: createTransactItems.length
|
|
8724
|
+
});
|
|
8606
8725
|
yield this.ddbUtils.executeTransactWrite({
|
|
8607
8726
|
TransactItems: createTransactItems
|
|
8608
8727
|
});
|
|
8728
|
+
console.log("[MONORISE_DEBUG] createMutual transaction succeeded");
|
|
8609
8729
|
if (asEntity && entity && ensureEntityStrongConsistentWrite) {
|
|
8610
8730
|
yield this.entityServiceLifeCycle.afterCreateEntityHook(
|
|
8611
8731
|
entity,
|
|
@@ -8644,6 +8764,7 @@ var MutualService = class {
|
|
|
8644
8764
|
})
|
|
8645
8765
|
];
|
|
8646
8766
|
yield Promise.all(eventPromises);
|
|
8767
|
+
console.log("[MONORISE_DEBUG] createMutual service complete");
|
|
8647
8768
|
return { mutual, eventPayload };
|
|
8648
8769
|
});
|
|
8649
8770
|
this.updateMutual = (_0) => __async(this, [_0], function* ({
|
|
@@ -8656,8 +8777,19 @@ var MutualService = class {
|
|
|
8656
8777
|
options
|
|
8657
8778
|
}) {
|
|
8658
8779
|
var _a;
|
|
8780
|
+
console.log("[MONORISE_DEBUG] updateMutual service start:", {
|
|
8781
|
+
byEntityType,
|
|
8782
|
+
byEntityId,
|
|
8783
|
+
entityType,
|
|
8784
|
+
entityId,
|
|
8785
|
+
mutualPayload,
|
|
8786
|
+
options
|
|
8787
|
+
});
|
|
8659
8788
|
const schema = (_a = this.getMutualDataSchema(byEntityType, entityType)) != null ? _a : external_exports.record(external_exports.string(), external_exports.any());
|
|
8789
|
+
console.log("[MONORISE_DEBUG] updateMutual schema resolved");
|
|
8660
8790
|
const parsedMutualPayload = schema.parse(mutualPayload);
|
|
8791
|
+
console.log("[MONORISE_DEBUG] updateMutual payload parsed:", parsedMutualPayload);
|
|
8792
|
+
console.log("[MONORISE_DEBUG] updateMutual calling repository...");
|
|
8661
8793
|
const mutual = yield this.mutualRepository.updateMutual(
|
|
8662
8794
|
byEntityType,
|
|
8663
8795
|
byEntityId,
|
|
@@ -8666,6 +8798,10 @@ var MutualService = class {
|
|
|
8666
8798
|
{ mutualData: parsedMutualPayload },
|
|
8667
8799
|
options
|
|
8668
8800
|
);
|
|
8801
|
+
console.log("[MONORISE_DEBUG] updateMutual repository result:", {
|
|
8802
|
+
hasMutual: !!mutual,
|
|
8803
|
+
mutualId: mutual == null ? void 0 : mutual.mutualId
|
|
8804
|
+
});
|
|
8669
8805
|
yield this.publishEvent({
|
|
8670
8806
|
event: EVENT.CORE.MUTUAL_UPDATED(byEntityType, entityType),
|
|
8671
8807
|
payload: {
|
|
@@ -8677,6 +8813,7 @@ var MutualService = class {
|
|
|
8677
8813
|
updatedByAccountId: accountId
|
|
8678
8814
|
}
|
|
8679
8815
|
});
|
|
8816
|
+
console.log("[MONORISE_DEBUG] updateMutual service complete");
|
|
8680
8817
|
return mutual;
|
|
8681
8818
|
});
|
|
8682
8819
|
this.deleteMutual = (_0) => __async(this, [_0], function* ({
|
|
@@ -9547,19 +9684,47 @@ var DependencyContainer = class {
|
|
|
9547
9684
|
}
|
|
9548
9685
|
};
|
|
9549
9686
|
|
|
9550
|
-
//
|
|
9687
|
+
// ../base/dist/index.js
|
|
9688
|
+
var __defProp = Object.defineProperty;
|
|
9689
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9690
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9691
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9692
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9693
|
+
var __spreadValues2 = (a, b) => {
|
|
9694
|
+
for (var prop in b || (b = {}))
|
|
9695
|
+
if (__hasOwnProp.call(b, prop))
|
|
9696
|
+
__defNormalProp(a, prop, b[prop]);
|
|
9697
|
+
if (__getOwnPropSymbols)
|
|
9698
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
9699
|
+
if (__propIsEnum.call(b, prop))
|
|
9700
|
+
__defNormalProp(a, prop, b[prop]);
|
|
9701
|
+
}
|
|
9702
|
+
return a;
|
|
9703
|
+
};
|
|
9704
|
+
var __objRest2 = (source, exclude) => {
|
|
9705
|
+
var target = {};
|
|
9706
|
+
for (var prop in source)
|
|
9707
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
9708
|
+
target[prop] = source[prop];
|
|
9709
|
+
if (source != null && __getOwnPropSymbols)
|
|
9710
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
9711
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
9712
|
+
target[prop] = source[prop];
|
|
9713
|
+
}
|
|
9714
|
+
return target;
|
|
9715
|
+
};
|
|
9551
9716
|
var transactional = {
|
|
9552
9717
|
createEntity: (entityType, payload) => {
|
|
9553
|
-
const _a = payload, { entityId } = _a, rest =
|
|
9554
|
-
return
|
|
9718
|
+
const _a = payload, { entityId } = _a, rest = __objRest2(_a, ["entityId"]);
|
|
9719
|
+
return __spreadValues2({
|
|
9555
9720
|
operation: "createEntity",
|
|
9556
9721
|
entityType,
|
|
9557
9722
|
payload: rest
|
|
9558
9723
|
}, entityId && { entityId });
|
|
9559
9724
|
},
|
|
9560
9725
|
updateEntity: (entityType, entityId, payload) => {
|
|
9561
|
-
const _a = payload, { $condition } = _a, rest =
|
|
9562
|
-
return
|
|
9726
|
+
const _a = payload, { $condition } = _a, rest = __objRest2(_a, ["$condition"]);
|
|
9727
|
+
return __spreadValues2({
|
|
9563
9728
|
operation: "updateEntity",
|
|
9564
9729
|
entityType,
|
|
9565
9730
|
entityId,
|
|
@@ -9567,8 +9732,8 @@ var transactional = {
|
|
|
9567
9732
|
}, $condition && { condition: $condition });
|
|
9568
9733
|
},
|
|
9569
9734
|
adjustEntity: (entityType, entityId, adjustments) => {
|
|
9570
|
-
const _a = adjustments, { $condition } = _a, rest =
|
|
9571
|
-
return
|
|
9735
|
+
const _a = adjustments, { $condition } = _a, rest = __objRest2(_a, ["$condition"]);
|
|
9736
|
+
return __spreadValues2({
|
|
9572
9737
|
operation: "adjustEntity",
|
|
9573
9738
|
entityType,
|
|
9574
9739
|
entityId,
|