@fonderie/customers 6.2.2 → 6.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.cjs +10 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1348,7 +1348,7 @@ var addRelationshipSchema = z.object({
|
|
|
1348
1348
|
import { withWorkspace } from "@fonderie/workspaces";
|
|
1349
1349
|
|
|
1350
1350
|
// src/controllers/customer.controller.ts
|
|
1351
|
-
import { HTTP, setApiResponse } from "@fonderie/core";
|
|
1351
|
+
import { HTTP, setApiResponse, background } from "@fonderie/core";
|
|
1352
1352
|
|
|
1353
1353
|
// src/utils.ts
|
|
1354
1354
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -1482,11 +1482,10 @@ function customerController(store, config = {}, bus) {
|
|
|
1482
1482
|
}
|
|
1483
1483
|
throw err;
|
|
1484
1484
|
}
|
|
1485
|
-
bus?.emit(EVENT_KEYS.customerCreated, {
|
|
1485
|
+
await background(bus?.emit(EVENT_KEYS.customerCreated, {
|
|
1486
1486
|
customerId: customer.id,
|
|
1487
1487
|
workspaceId: customer.workspaceId
|
|
1488
|
-
})
|
|
1489
|
-
});
|
|
1488
|
+
}));
|
|
1490
1489
|
return setApiResponse(HTTP.CREATED, "CUSTOMER_CREATED", "Customer created successfully.", {
|
|
1491
1490
|
customer: toCustomerDTO(customer)
|
|
1492
1491
|
});
|
|
@@ -1551,11 +1550,10 @@ function customerController(store, config = {}, bus) {
|
|
|
1551
1550
|
if (!customer) {
|
|
1552
1551
|
return setApiResponse(HTTP.NOT_FOUND, "NOT_FOUND", "Customer not found");
|
|
1553
1552
|
}
|
|
1554
|
-
bus?.emit(EVENT_KEYS.customerUpdated, {
|
|
1553
|
+
await background(bus?.emit(EVENT_KEYS.customerUpdated, {
|
|
1555
1554
|
customerId: customer.id,
|
|
1556
1555
|
workspaceId: customer.workspaceId
|
|
1557
|
-
})
|
|
1558
|
-
});
|
|
1556
|
+
}));
|
|
1559
1557
|
return setApiResponse(HTTP.OK, "CUSTOMER_UPDATED", "Customer updated successfully.", {
|
|
1560
1558
|
customer: toCustomerDTO(customer)
|
|
1561
1559
|
});
|
|
@@ -1579,11 +1577,10 @@ function customerController(store, config = {}, bus) {
|
|
|
1579
1577
|
return setApiResponse(HTTP.NOT_FOUND, "NOT_FOUND", "Customer not found");
|
|
1580
1578
|
}
|
|
1581
1579
|
await customers.delete(id, workspaceId);
|
|
1582
|
-
bus?.emit(EVENT_KEYS.customerDeleted, {
|
|
1580
|
+
await background(bus?.emit(EVENT_KEYS.customerDeleted, {
|
|
1583
1581
|
customerId: id,
|
|
1584
1582
|
workspaceId
|
|
1585
|
-
})
|
|
1586
|
-
});
|
|
1583
|
+
}));
|
|
1587
1584
|
return setApiResponse(HTTP.OK, "CUSTOMER_DELETED", "Customer deleted successfully.");
|
|
1588
1585
|
},
|
|
1589
1586
|
async blacklist(ctx) {
|
|
@@ -1607,11 +1604,10 @@ function customerController(store, config = {}, bus) {
|
|
|
1607
1604
|
const body = ctx.meta["body"];
|
|
1608
1605
|
const reason = typeof body?.["reason"] === "string" ? body["reason"].trim() || null : null;
|
|
1609
1606
|
await customers.blacklist(id, workspaceId, reason);
|
|
1610
|
-
bus?.emit(EVENT_KEYS.customerBlacklisted, {
|
|
1607
|
+
await background(bus?.emit(EVENT_KEYS.customerBlacklisted, {
|
|
1611
1608
|
customerId: id,
|
|
1612
1609
|
workspaceId
|
|
1613
|
-
})
|
|
1614
|
-
});
|
|
1610
|
+
}));
|
|
1615
1611
|
return setApiResponse(HTTP.OK, "CUSTOMER_BLACKLISTED", "Customer blacklisted successfully.");
|
|
1616
1612
|
},
|
|
1617
1613
|
async unblacklist(ctx) {
|
|
@@ -1633,11 +1629,10 @@ function customerController(store, config = {}, bus) {
|
|
|
1633
1629
|
return setApiResponse(HTTP.NOT_FOUND, "NOT_FOUND", "Customer not found");
|
|
1634
1630
|
}
|
|
1635
1631
|
await customers.unblacklist(id, workspaceId);
|
|
1636
|
-
bus?.emit(EVENT_KEYS.customerUnblacklisted, {
|
|
1632
|
+
await background(bus?.emit(EVENT_KEYS.customerUnblacklisted, {
|
|
1637
1633
|
customerId: id,
|
|
1638
1634
|
workspaceId
|
|
1639
|
-
})
|
|
1640
|
-
});
|
|
1635
|
+
}));
|
|
1641
1636
|
return setApiResponse(HTTP.OK, "CUSTOMER_UNBLACKLISTED", "Customer removed from blacklist successfully.");
|
|
1642
1637
|
}
|
|
1643
1638
|
};
|