@kumori/aurora-backend-handler 1.0.125 → 1.0.127
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/helpers/account-helper.ts +12 -1
- package/package.json +1 -1
- package/websocket-manager.ts +3 -2
|
@@ -39,6 +39,7 @@ interface HandleAccountOperationSuccessParams {
|
|
|
39
39
|
action: string;
|
|
40
40
|
entityName: string;
|
|
41
41
|
originalData: Account;
|
|
42
|
+
existingAccount?: Account;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
interface HandleAccountOperationSuccessResult {
|
|
@@ -275,6 +276,12 @@ export const handleAccountEvent = ({
|
|
|
275
276
|
};
|
|
276
277
|
};
|
|
277
278
|
|
|
279
|
+
|
|
280
|
+
const resolveStatusAfterCreate = (existingAccount?: Account): string =>
|
|
281
|
+
existingAccount?.status && existingAccount.status !== "pending"
|
|
282
|
+
? existingAccount.status
|
|
283
|
+
: "pending";
|
|
284
|
+
|
|
278
285
|
/**
|
|
279
286
|
* Handles successful account operations (CREATE, UPDATE, DELETE).
|
|
280
287
|
*/
|
|
@@ -282,6 +289,7 @@ export const handleAccountOperationSuccess = ({
|
|
|
282
289
|
action,
|
|
283
290
|
entityName,
|
|
284
291
|
originalData,
|
|
292
|
+
existingAccount,
|
|
285
293
|
}: HandleAccountOperationSuccessParams): HandleAccountOperationSuccessResult => {
|
|
286
294
|
if (action === "DELETE") {
|
|
287
295
|
return {
|
|
@@ -300,8 +308,11 @@ export const handleAccountOperationSuccess = ({
|
|
|
300
308
|
}
|
|
301
309
|
|
|
302
310
|
if (originalData) {
|
|
303
|
-
const updatedAccount: Account = { ...originalData, status: "active" };
|
|
304
311
|
const isCreate = action === "CREATE";
|
|
312
|
+
const updatedAccount: Account = {
|
|
313
|
+
...originalData,
|
|
314
|
+
status: isCreate ? resolveStatusAfterCreate(existingAccount) : "active",
|
|
315
|
+
};
|
|
305
316
|
|
|
306
317
|
return {
|
|
307
318
|
updatedAccount,
|
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -1547,14 +1547,15 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1547
1547
|
}
|
|
1548
1548
|
break;
|
|
1549
1549
|
case "account":
|
|
1550
|
+
const accTenant = (originalData as Account)?.tenant;
|
|
1551
|
+
const accSuccessKey = accTenant ? `${accTenant}/${entityName}` : entityName;
|
|
1550
1552
|
const accSuccessResult = handleAccountOperationSuccess({
|
|
1551
1553
|
action,
|
|
1552
1554
|
entityName,
|
|
1553
1555
|
originalData: originalData as Account,
|
|
1556
|
+
existingAccount: accountsMap.get(accSuccessKey),
|
|
1554
1557
|
});
|
|
1555
1558
|
|
|
1556
|
-
const accTenant = (originalData as Account)?.tenant;
|
|
1557
|
-
const accSuccessKey = accTenant ? `${accTenant}/${entityName}` : entityName;
|
|
1558
1559
|
if (accSuccessResult.shouldDelete) {
|
|
1559
1560
|
const acc = accountsMap.get(accSuccessKey);
|
|
1560
1561
|
if (acc) {
|