@sendhome/common 1.0.184 → 1.0.185
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/build/events/publishers/activity-created.d.ts +24 -0
- package/build/events/publishers/activity-created.js +2 -0
- package/build/events/subjects/subjects.d.ts +2 -1
- package/build/events/subjects/subjects.js +2 -0
- package/build/events/types/activity-type.d.ts +15 -0
- package/build/events/types/activity-type.js +19 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/utils/activity-logger.d.ts +21 -0
- package/build/utils/activity-logger.js +28 -0
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Subjects } from "../subjects/subjects";
|
|
2
|
+
import { ActivityType } from "../types/activity-type";
|
|
3
|
+
import { AccountType } from "../types/account-type";
|
|
4
|
+
export interface ActivityCreatedEvent {
|
|
5
|
+
subject: Subjects.ActivityCreated;
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
user: string;
|
|
9
|
+
account_type: AccountType;
|
|
10
|
+
activity: ActivityType;
|
|
11
|
+
resource: string;
|
|
12
|
+
changes: Record<string, {
|
|
13
|
+
oldValue: any;
|
|
14
|
+
newValue: any;
|
|
15
|
+
}>;
|
|
16
|
+
details: string;
|
|
17
|
+
metadata: {
|
|
18
|
+
ip: string;
|
|
19
|
+
user_agent: string;
|
|
20
|
+
};
|
|
21
|
+
created_at: Date;
|
|
22
|
+
version: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum ActivityType {
|
|
2
|
+
user_signin = "userSignin",
|
|
3
|
+
recipient_created = "recipientCreated",
|
|
4
|
+
recipient_updated = "recipientUpdated",
|
|
5
|
+
viewed_sellers = "viewedSellers",
|
|
6
|
+
entered_shop = "enteredShop",
|
|
7
|
+
order_paid = "orderPaid",
|
|
8
|
+
order_cancelled = "orderCancelled",
|
|
9
|
+
order_recipient_changed = "orderRecipientChanged",
|
|
10
|
+
order_recipient_downloaded = "orderRecipientDownloaded",
|
|
11
|
+
product_created = "productCreated",
|
|
12
|
+
product_updated = "productUpdated",
|
|
13
|
+
seller_registered = "sellerRegistered",
|
|
14
|
+
seller_updated = "sellerUpdated"
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActivityType = void 0;
|
|
4
|
+
var ActivityType;
|
|
5
|
+
(function (ActivityType) {
|
|
6
|
+
ActivityType["user_signin"] = "userSignin";
|
|
7
|
+
ActivityType["recipient_created"] = "recipientCreated";
|
|
8
|
+
ActivityType["recipient_updated"] = "recipientUpdated";
|
|
9
|
+
ActivityType["viewed_sellers"] = "viewedSellers";
|
|
10
|
+
ActivityType["entered_shop"] = "enteredShop";
|
|
11
|
+
ActivityType["order_paid"] = "orderPaid";
|
|
12
|
+
ActivityType["order_cancelled"] = "orderCancelled";
|
|
13
|
+
ActivityType["order_recipient_changed"] = "orderRecipientChanged";
|
|
14
|
+
ActivityType["order_recipient_downloaded"] = "orderRecipientDownloaded";
|
|
15
|
+
ActivityType["product_created"] = "productCreated";
|
|
16
|
+
ActivityType["product_updated"] = "productUpdated";
|
|
17
|
+
ActivityType["seller_registered"] = "sellerRegistered";
|
|
18
|
+
ActivityType["seller_updated"] = "sellerUpdated";
|
|
19
|
+
})(ActivityType = exports.ActivityType || (exports.ActivityType = {}));
|
package/build/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./events/subjects/subjects";
|
|
|
15
15
|
export * from "./events/publishers/bonus-awarded-event";
|
|
16
16
|
export * from "./events/publishers/branch-created-event";
|
|
17
17
|
export * from "./events/publishers/branch-updated-event";
|
|
18
|
+
export * from "./events/publishers/activity-created";
|
|
18
19
|
export * from "./events/publishers/brand-created-event";
|
|
19
20
|
export * from "./events/publishers/brand-updated-event";
|
|
20
21
|
export * from "./events/publishers/cart-created-event";
|
|
@@ -67,6 +68,7 @@ export * from "./events/publishers/topic-updated-event";
|
|
|
67
68
|
export * from "./events/publishers/user-created-event";
|
|
68
69
|
export * from "./events/publishers/user-updated-event";
|
|
69
70
|
export * from "./events/types/account-type";
|
|
71
|
+
export * from "./events/types/activity-type";
|
|
70
72
|
export * from "./events/types/admin-levels";
|
|
71
73
|
export * from "./events/types/branch-status";
|
|
72
74
|
export * from "./events/types/brand-status";
|
package/build/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __exportStar(require("./events/subjects/subjects"), exports);
|
|
|
28
28
|
__exportStar(require("./events/publishers/bonus-awarded-event"), exports);
|
|
29
29
|
__exportStar(require("./events/publishers/branch-created-event"), exports);
|
|
30
30
|
__exportStar(require("./events/publishers/branch-updated-event"), exports);
|
|
31
|
+
__exportStar(require("./events/publishers/activity-created"), exports);
|
|
31
32
|
__exportStar(require("./events/publishers/brand-created-event"), exports);
|
|
32
33
|
__exportStar(require("./events/publishers/brand-updated-event"), exports);
|
|
33
34
|
__exportStar(require("./events/publishers/cart-created-event"), exports);
|
|
@@ -80,6 +81,7 @@ __exportStar(require("./events/publishers/topic-updated-event"), exports);
|
|
|
80
81
|
__exportStar(require("./events/publishers/user-created-event"), exports);
|
|
81
82
|
__exportStar(require("./events/publishers/user-updated-event"), exports);
|
|
82
83
|
__exportStar(require("./events/types/account-type"), exports);
|
|
84
|
+
__exportStar(require("./events/types/activity-type"), exports);
|
|
83
85
|
__exportStar(require("./events/types/admin-levels"), exports);
|
|
84
86
|
__exportStar(require("./events/types/branch-status"), exports);
|
|
85
87
|
__exportStar(require("./events/types/brand-status"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Stan } from "node-nats-streaming";
|
|
2
|
+
import { ActivityType } from "../events/types/activity-type";
|
|
3
|
+
import { AccountType } from "../events/types/account-type";
|
|
4
|
+
interface ActivityLogData {
|
|
5
|
+
user: string;
|
|
6
|
+
account_type: AccountType;
|
|
7
|
+
activity: ActivityType;
|
|
8
|
+
resource: string;
|
|
9
|
+
changes: Record<string, {
|
|
10
|
+
oldValue: any;
|
|
11
|
+
newValue: any;
|
|
12
|
+
}>;
|
|
13
|
+
details: string;
|
|
14
|
+
metadata: {
|
|
15
|
+
ip: string;
|
|
16
|
+
user_agent: string;
|
|
17
|
+
};
|
|
18
|
+
created_at: Date;
|
|
19
|
+
}
|
|
20
|
+
export declare const logActivity: (stan: Stan, activityLog: ActivityLogData) => Promise<void>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.logActivity = void 0;
|
|
13
|
+
const logActivity = (stan, activityLog) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
stan.publish("activity:log", JSON.stringify(activityLog), (err, guid) => {
|
|
16
|
+
if (err) {
|
|
17
|
+
console.error("Failed to publish activity log:", err);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log(`Activity log published with guid: ${guid}`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error("Error in activity logger:", error);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
exports.logActivity = logActivity;
|