@heliyos/heliyos-api-core 1.0.46 → 1.0.48
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/authentication.js +3 -1
- package/dist/events.d.ts +25 -13
- package/dist/events.js +30 -83
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
package/dist/authentication.js
CHANGED
|
@@ -233,13 +233,14 @@ const setLoggedInUser = function (container, req) {
|
|
|
233
233
|
//
|
|
234
234
|
// Handle Cookie and Bearer token
|
|
235
235
|
const { output: { loggedInUser }, } = container;
|
|
236
|
-
const { token, userId, organizationId, role } = loggedInUser;
|
|
236
|
+
const { token, userId, organizationId, role, userFullName } = loggedInUser;
|
|
237
237
|
// Modify req object with logged in user data
|
|
238
238
|
req.loggedInUser = {
|
|
239
239
|
token,
|
|
240
240
|
userId,
|
|
241
241
|
organizationId,
|
|
242
242
|
role,
|
|
243
|
+
userFullName,
|
|
243
244
|
auth_type,
|
|
244
245
|
};
|
|
245
246
|
return undefined;
|
|
@@ -264,6 +265,7 @@ const callAuthApiServer = (token) => __awaiter(void 0, void 0, void 0, function*
|
|
|
264
265
|
userId: authResult.data.data.payload.userId,
|
|
265
266
|
organizationId: authResult.data.data.payload.organizationId,
|
|
266
267
|
role: authResult.data.data.payload.role,
|
|
268
|
+
userFullName: authResult.data.data.payload.userFullName,
|
|
267
269
|
};
|
|
268
270
|
}
|
|
269
271
|
else {
|
package/dist/events.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
export declare enum EventType {
|
|
2
2
|
AUDIT = "AUDIT",
|
|
3
|
-
INTERACTION = "INTERACTION"
|
|
3
|
+
INTERACTION = "INTERACTION",
|
|
4
|
+
ENRICHMENT = "ENRICHMENT"
|
|
4
5
|
}
|
|
5
6
|
export declare enum ActorType {
|
|
6
7
|
USER = "USER",
|
|
7
8
|
SYSTEM = "SYSTEM",
|
|
8
9
|
AGENT = "AGENT"
|
|
9
10
|
}
|
|
11
|
+
export declare enum OperationType {
|
|
12
|
+
CREATE = "CREATE",
|
|
13
|
+
UPDATE = "UPDATE",
|
|
14
|
+
DELETE = "DELETE"
|
|
15
|
+
}
|
|
10
16
|
interface IActor {
|
|
11
17
|
type: ActorType;
|
|
12
18
|
uuid: string;
|
|
19
|
+
name?: string;
|
|
13
20
|
}
|
|
14
21
|
interface IEventMetadata {
|
|
15
22
|
eventType: EventType;
|
|
@@ -17,35 +24,40 @@ interface IEventMetadata {
|
|
|
17
24
|
organizationUUID: string;
|
|
18
25
|
objectType: string;
|
|
19
26
|
objectUUID: string;
|
|
27
|
+
operationType: OperationType;
|
|
20
28
|
}
|
|
21
29
|
/**
|
|
22
|
-
* Creates a timestamped event log entry
|
|
30
|
+
* Creates a timestamped event log entry by calling the agent server API
|
|
23
31
|
*
|
|
24
32
|
* @param metadata - Event metadata object containing:
|
|
25
33
|
* - eventType: Type of event (AUDIT/INTERACTION)
|
|
26
|
-
* - actor: Who performed the action (
|
|
34
|
+
* - actor: Who performed the action (type, uuid, and optional name)
|
|
27
35
|
* - organizationUUID: Organization identifier
|
|
28
36
|
* - objectType: Type of object being modified (e.g., 'User', 'Document')
|
|
29
37
|
* - objectUUID: Unique identifier of the modified object
|
|
38
|
+
* - operationType: Type of operation (CREATE/UPDATE/DELETE)
|
|
30
39
|
* @param originalVersion - The state of the object before changes
|
|
31
40
|
* @param updatedVersion - The state of the object after changes
|
|
32
|
-
* @param changeSummary - Human-readable description of what changed
|
|
33
41
|
*
|
|
34
42
|
* @example
|
|
35
43
|
* await logEvent(
|
|
36
44
|
* {
|
|
37
45
|
* eventType: EventType.AUDIT,
|
|
38
|
-
* actor: {
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
46
|
+
* actor: {
|
|
47
|
+
* type: ActorType.USER,
|
|
48
|
+
* uuid: '672e282a2a2afba5140a2335',
|
|
49
|
+
* name: 'John Doe'
|
|
50
|
+
* },
|
|
51
|
+
* organizationUUID: '672e18445d218d5ab84790d2',
|
|
52
|
+
* objectType: 'company',
|
|
53
|
+
* objectUUID: '67ab795510d7869eb0c60879',
|
|
54
|
+
* operationType: OperationType.UPDATE
|
|
42
55
|
* },
|
|
43
|
-
* { name: '
|
|
44
|
-
* { name: '
|
|
45
|
-
* 'Updated user name from John to John Doe'
|
|
56
|
+
* { name: 'Old Name' },
|
|
57
|
+
* { name: 'New Name' }
|
|
46
58
|
* );
|
|
47
59
|
*
|
|
48
|
-
* @throws Will throw an error if the
|
|
60
|
+
* @throws Will throw an error if the API call fails
|
|
49
61
|
*/
|
|
50
|
-
export declare function logEvent(metadata: IEventMetadata, originalVersion: any, updatedVersion: any
|
|
62
|
+
export declare function logEvent(metadata: IEventMetadata, originalVersion: any, updatedVersion: any): Promise<void>;
|
|
51
63
|
export {};
|
package/dist/events.js
CHANGED
|
@@ -9,15 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ActorType = exports.EventType = void 0;
|
|
12
|
+
exports.OperationType = exports.ActorType = exports.EventType = void 0;
|
|
13
13
|
exports.logEvent = logEvent;
|
|
14
|
-
const mongoose_1 = require("./mongoose");
|
|
15
14
|
const logger_1 = require("./logger");
|
|
15
|
+
const _1 = require(".");
|
|
16
16
|
// Define the event types and actor types
|
|
17
17
|
var EventType;
|
|
18
18
|
(function (EventType) {
|
|
19
19
|
EventType["AUDIT"] = "AUDIT";
|
|
20
20
|
EventType["INTERACTION"] = "INTERACTION";
|
|
21
|
+
EventType["ENRICHMENT"] = "ENRICHMENT";
|
|
21
22
|
})(EventType || (exports.EventType = EventType = {}));
|
|
22
23
|
var ActorType;
|
|
23
24
|
(function (ActorType) {
|
|
@@ -25,113 +26,59 @@ var ActorType;
|
|
|
25
26
|
ActorType["SYSTEM"] = "SYSTEM";
|
|
26
27
|
ActorType["AGENT"] = "AGENT";
|
|
27
28
|
})(ActorType || (exports.ActorType = ActorType = {}));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
metadata: {
|
|
36
|
-
eventType: {
|
|
37
|
-
type: String,
|
|
38
|
-
enum: Object.values(EventType),
|
|
39
|
-
required: true
|
|
40
|
-
},
|
|
41
|
-
actor: {
|
|
42
|
-
type: {
|
|
43
|
-
type: String,
|
|
44
|
-
enum: Object.values(ActorType),
|
|
45
|
-
required: true
|
|
46
|
-
},
|
|
47
|
-
uuid: {
|
|
48
|
-
type: String,
|
|
49
|
-
required: true
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
organizationUUID: {
|
|
53
|
-
type: String,
|
|
54
|
-
required: true,
|
|
55
|
-
index: true
|
|
56
|
-
},
|
|
57
|
-
objectType: {
|
|
58
|
-
type: String,
|
|
59
|
-
required: true,
|
|
60
|
-
index: true
|
|
61
|
-
},
|
|
62
|
-
objectUUID: {
|
|
63
|
-
type: String,
|
|
64
|
-
required: true,
|
|
65
|
-
index: true
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
originalVersion: {
|
|
69
|
-
type: mongoose_1.Schema.Types.Mixed,
|
|
70
|
-
required: true
|
|
71
|
-
},
|
|
72
|
-
updatedVersion: {
|
|
73
|
-
type: mongoose_1.Schema.Types.Mixed,
|
|
74
|
-
required: true
|
|
75
|
-
},
|
|
76
|
-
changeSummary: {
|
|
77
|
-
type: String,
|
|
78
|
-
required: true
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
collection: 'events',
|
|
82
|
-
timeseries: {
|
|
83
|
-
timeField: 'timestamp',
|
|
84
|
-
metaField: 'metadata',
|
|
85
|
-
granularity: 'seconds'
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
// Create the model
|
|
89
|
-
const Event = (0, mongoose_1.model)('events', eventSchema);
|
|
29
|
+
var OperationType;
|
|
30
|
+
(function (OperationType) {
|
|
31
|
+
OperationType["CREATE"] = "CREATE";
|
|
32
|
+
OperationType["UPDATE"] = "UPDATE";
|
|
33
|
+
OperationType["DELETE"] = "DELETE";
|
|
34
|
+
})(OperationType || (exports.OperationType = OperationType = {}));
|
|
90
35
|
/**
|
|
91
|
-
* Creates a timestamped event log entry
|
|
36
|
+
* Creates a timestamped event log entry by calling the agent server API
|
|
92
37
|
*
|
|
93
38
|
* @param metadata - Event metadata object containing:
|
|
94
39
|
* - eventType: Type of event (AUDIT/INTERACTION)
|
|
95
|
-
* - actor: Who performed the action (
|
|
40
|
+
* - actor: Who performed the action (type, uuid, and optional name)
|
|
96
41
|
* - organizationUUID: Organization identifier
|
|
97
42
|
* - objectType: Type of object being modified (e.g., 'User', 'Document')
|
|
98
43
|
* - objectUUID: Unique identifier of the modified object
|
|
44
|
+
* - operationType: Type of operation (CREATE/UPDATE/DELETE)
|
|
99
45
|
* @param originalVersion - The state of the object before changes
|
|
100
46
|
* @param updatedVersion - The state of the object after changes
|
|
101
|
-
* @param changeSummary - Human-readable description of what changed
|
|
102
47
|
*
|
|
103
48
|
* @example
|
|
104
49
|
* await logEvent(
|
|
105
50
|
* {
|
|
106
51
|
* eventType: EventType.AUDIT,
|
|
107
|
-
* actor: {
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
52
|
+
* actor: {
|
|
53
|
+
* type: ActorType.USER,
|
|
54
|
+
* uuid: '672e282a2a2afba5140a2335',
|
|
55
|
+
* name: 'John Doe'
|
|
56
|
+
* },
|
|
57
|
+
* organizationUUID: '672e18445d218d5ab84790d2',
|
|
58
|
+
* objectType: 'company',
|
|
59
|
+
* objectUUID: '67ab795510d7869eb0c60879',
|
|
60
|
+
* operationType: OperationType.UPDATE
|
|
111
61
|
* },
|
|
112
|
-
* { name: '
|
|
113
|
-
* { name: '
|
|
114
|
-
* 'Updated user name from John to John Doe'
|
|
62
|
+
* { name: 'Old Name' },
|
|
63
|
+
* { name: 'New Name' }
|
|
115
64
|
* );
|
|
116
65
|
*
|
|
117
|
-
* @throws Will throw an error if the
|
|
66
|
+
* @throws Will throw an error if the API call fails
|
|
118
67
|
*/
|
|
119
|
-
function logEvent(metadata, originalVersion, updatedVersion
|
|
68
|
+
function logEvent(metadata, originalVersion, updatedVersion) {
|
|
120
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
70
|
try {
|
|
122
|
-
|
|
123
|
-
timestamp: new Date(),
|
|
71
|
+
const payload = {
|
|
124
72
|
metadata,
|
|
125
73
|
originalVersion,
|
|
126
|
-
updatedVersion
|
|
127
|
-
|
|
128
|
-
|
|
74
|
+
updatedVersion
|
|
75
|
+
};
|
|
76
|
+
yield _1.axios.agentServer.post('/v1/agent/log-event', payload);
|
|
129
77
|
}
|
|
130
78
|
catch (error) {
|
|
131
79
|
logger_1.logger.error('Failed to create event log', {
|
|
132
80
|
error,
|
|
133
|
-
metadata
|
|
134
|
-
changeSummary
|
|
81
|
+
metadata
|
|
135
82
|
});
|
|
136
83
|
throw error;
|
|
137
84
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,4 +19,4 @@ export { HttpError } from "./@types/globals/customError";
|
|
|
19
19
|
export type { ICoreAppOptions } from "./@types/globals/middleware";
|
|
20
20
|
export type { RolesPermissionsType, ResourcePolicyActionsType, } from "./static/authPolicyFile";
|
|
21
21
|
export { Schema, Document, Model, FilterQuery, UpdateQuery, Pagination, Types, mongooseConnection, mongoInstance, } from "./mongoose";
|
|
22
|
-
export { logEvent, EventType, ActorType } from './events';
|
|
22
|
+
export { logEvent, EventType, ActorType, OperationType } from './events';
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ActorType = exports.EventType = exports.logEvent = exports.mongoInstance = exports.mongooseConnection = exports.Types = exports.Model = exports.Document = exports.Schema = exports.HttpError = exports.getSecretsManagerSecret = exports.resendSendEmail = exports.pusherTriggerBatch = exports.pusherTrigger = exports.pusher = exports.emailTemplates = exports.getEmailTemplate = exports.allowedOrigin = exports.logger = exports.SQSUtil = exports.getRedisClient = exports.authorizeUser = exports.authPolicy = exports.loadAppEnv = exports.joiObject = exports.validate = exports.axios = exports.coreApp = exports.authentication = void 0;
|
|
26
|
+
exports.OperationType = exports.ActorType = exports.EventType = exports.logEvent = exports.mongoInstance = exports.mongooseConnection = exports.Types = exports.Model = exports.Document = exports.Schema = exports.HttpError = exports.getSecretsManagerSecret = exports.resendSendEmail = exports.pusherTriggerBatch = exports.pusherTrigger = exports.pusher = exports.emailTemplates = exports.getEmailTemplate = exports.allowedOrigin = exports.logger = exports.SQSUtil = exports.getRedisClient = exports.authorizeUser = exports.authPolicy = exports.loadAppEnv = exports.joiObject = exports.validate = exports.axios = exports.coreApp = exports.authentication = void 0;
|
|
27
27
|
const dotenv = __importStar(require("dotenv"));
|
|
28
28
|
dotenv.config();
|
|
29
29
|
// Core exports
|
|
@@ -76,3 +76,4 @@ var events_1 = require("./events");
|
|
|
76
76
|
Object.defineProperty(exports, "logEvent", { enumerable: true, get: function () { return events_1.logEvent; } });
|
|
77
77
|
Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return events_1.EventType; } });
|
|
78
78
|
Object.defineProperty(exports, "ActorType", { enumerable: true, get: function () { return events_1.ActorType; } });
|
|
79
|
+
Object.defineProperty(exports, "OperationType", { enumerable: true, get: function () { return events_1.OperationType; } });
|