@payfit/audit-log 1.0.0-alpha4 → 1.0.0-alpha7
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 +73 -7
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/dist/transport/generated/model/index.js +0 -4
- package/dist/transport/generated/model/index.js.map +1 -1
- package/dist/transport/generated/model/inline-object.d.ts +1 -12
- package/dist/transport/generated/model/inline-object.js +0 -12
- package/dist/transport/generated/model/inline-object.js.map +1 -1
- package/dist/transport/implementation.d.ts +8 -2
- package/dist/transport/implementation.js +16 -10
- package/dist/transport/implementation.js.map +1 -1
- package/dist/transport/interface.d.ts +6 -2
- package/package.json +2 -1
- package/playground/index.ts +25 -0
- package/src/index.ts +112 -23
- package/src/transport/generated/model/inline-object.ts +1 -14
- package/src/transport/implementation.ts +19 -13
- package/src/transport/interface.ts +7 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Data to audit log.
|
|
3
|
+
*/
|
|
4
|
+
export interface IAuditLogData {
|
|
5
|
+
/**
|
|
6
|
+
* The data specific to the audit log.
|
|
7
|
+
* For example, if we add a bonus to an employee, it could contain the amount, the impacted employeeId, etc...
|
|
8
|
+
*/
|
|
3
9
|
payload?: object;
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The buisness domain impacted.
|
|
12
|
+
* e.g documents, authentication, ...
|
|
13
|
+
*/
|
|
6
14
|
namespace: string;
|
|
15
|
+
/**
|
|
16
|
+
* The service name (tech).
|
|
17
|
+
* e.g files, payroll-api-v2, auth, ...
|
|
18
|
+
*/
|
|
7
19
|
service: string;
|
|
20
|
+
/**
|
|
21
|
+
* The name of the event.
|
|
22
|
+
* e.g. signIn, passwordUpdated, bonusAdded, ...
|
|
23
|
+
*/
|
|
8
24
|
event: string;
|
|
25
|
+
/**
|
|
26
|
+
* The data that describes who did perform the logged action.
|
|
27
|
+
*/
|
|
28
|
+
account: IAuditLogAuthData;
|
|
29
|
+
/**
|
|
30
|
+
* The scope of the audit log
|
|
31
|
+
*/
|
|
32
|
+
scope: IAuditLogScope;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Data used to indentify who performed an action
|
|
36
|
+
*/
|
|
37
|
+
export declare type IAuditLogAuthData = {
|
|
38
|
+
/**
|
|
39
|
+
* Tells if the action has been made during a siginAs
|
|
40
|
+
*/
|
|
41
|
+
isImpersonated?: boolean;
|
|
9
42
|
holdingId?: string;
|
|
10
43
|
companyId?: string;
|
|
11
44
|
employeeId?: string;
|
|
12
|
-
individualId
|
|
45
|
+
individualId: string;
|
|
13
46
|
roleId?: string;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
countryCode?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The IP address of the user
|
|
53
|
+
*/
|
|
14
54
|
userIp?: string;
|
|
15
|
-
|
|
55
|
+
/**
|
|
56
|
+
* The email address of the user
|
|
57
|
+
*/
|
|
16
58
|
email?: string;
|
|
59
|
+
} | {
|
|
60
|
+
isSystem: true;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Data used to "scope" the audit log.
|
|
64
|
+
* Might be useful to retrieve all actions performed in a holding, a company, or on an employee.
|
|
65
|
+
*/
|
|
66
|
+
export declare type IAuditLogScope = {
|
|
67
|
+
holdingId: string;
|
|
68
|
+
} | {
|
|
69
|
+
companyId: string;
|
|
70
|
+
employeeId?: string;
|
|
71
|
+
} | null;
|
|
72
|
+
export interface IAuditLogger {
|
|
73
|
+
log: (data: IAuditLogData) => Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
export interface IAuditLoggerInitialization {
|
|
76
|
+
apiUrl: string;
|
|
77
|
+
environment: string;
|
|
78
|
+
}
|
|
79
|
+
export declare class AuditLogger implements IAuditLogger {
|
|
80
|
+
protected params: IAuditLoggerInitialization;
|
|
81
|
+
private transport;
|
|
82
|
+
constructor(params: IAuditLoggerInitialization);
|
|
83
|
+
log(params: IAuditLogData): Promise<void>;
|
|
17
84
|
}
|
|
18
|
-
export declare function auditLog(params: AuditLogData): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -7,25 +7,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
11
|
-
if (mod && mod.__esModule) return mod;
|
|
12
|
-
var result = {};
|
|
13
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
14
|
-
result["default"] = mod;
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
11
|
const uuid_1 = require("uuid");
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
const implementation_1 = require("./transport/implementation");
|
|
13
|
+
class AuditLogger {
|
|
14
|
+
constructor(params) {
|
|
15
|
+
this.params = params;
|
|
16
|
+
this.transport = new implementation_1.Transport(params.apiUrl);
|
|
17
|
+
}
|
|
18
|
+
log(params) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const uuid = uuid_1.v4();
|
|
21
|
+
const environment = this.params.environment;
|
|
22
|
+
const timestamp = new Date().getTime();
|
|
23
|
+
const log = Object.assign({}, params, { id: uuid, environment,
|
|
24
|
+
timestamp });
|
|
25
|
+
yield this.transport.create(log);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
29
28
|
}
|
|
30
|
-
exports.
|
|
29
|
+
exports.AuditLogger = AuditLogger;
|
|
31
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,+BAAmC;AAEnC,+DAAsD;AAoGtD,MAAa,WAAW;IAGtB,YAAsB,MAAkC;QAAlC,WAAM,GAAN,MAAM,CAA4B;QACtD,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IAEK,GAAG,CAAC,MAAqB;;YAC7B,MAAM,IAAI,GAAG,SAAM,EAAE,CAAA;YACrB,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAA;YAC3C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;YAEtC,MAAM,GAAG,qBACJ,MAAM,IACT,EAAE,EAAE,IAAI,EACR,WAAW;gBACX,SAAS,GACV,CAAA;YAED,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAClC,CAAC;KAAA;CACF;AArBD,kCAqBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transport/generated/model/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transport/generated/model/index.ts"],"names":[],"mappings":""}
|
|
@@ -26,7 +26,7 @@ export interface InlineObject {
|
|
|
26
26
|
* @type {string}
|
|
27
27
|
* @memberof InlineObject
|
|
28
28
|
*/
|
|
29
|
-
countryCode
|
|
29
|
+
countryCode?: string;
|
|
30
30
|
/**
|
|
31
31
|
* Audit log event payload
|
|
32
32
|
* @type {object}
|
|
@@ -118,14 +118,3 @@ export interface InlineObject {
|
|
|
118
118
|
*/
|
|
119
119
|
email?: string;
|
|
120
120
|
}
|
|
121
|
-
/**
|
|
122
|
-
* @export
|
|
123
|
-
* @enum {string}
|
|
124
|
-
*/
|
|
125
|
-
export declare enum CountryCodeEnum {
|
|
126
|
-
FR = "fr",
|
|
127
|
-
DE = "de",
|
|
128
|
-
IT = "it",
|
|
129
|
-
ES = "es",
|
|
130
|
-
GB = "gb"
|
|
131
|
-
}
|
|
@@ -12,16 +12,4 @@
|
|
|
12
12
|
* Do not edit the class manually.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
/**
|
|
16
|
-
* @export
|
|
17
|
-
* @enum {string}
|
|
18
|
-
*/
|
|
19
|
-
var CountryCodeEnum;
|
|
20
|
-
(function (CountryCodeEnum) {
|
|
21
|
-
CountryCodeEnum["FR"] = "fr";
|
|
22
|
-
CountryCodeEnum["DE"] = "de";
|
|
23
|
-
CountryCodeEnum["IT"] = "it";
|
|
24
|
-
CountryCodeEnum["ES"] = "es";
|
|
25
|
-
CountryCodeEnum["GB"] = "gb";
|
|
26
|
-
})(CountryCodeEnum = exports.CountryCodeEnum || (exports.CountryCodeEnum = {}));
|
|
27
15
|
//# sourceMappingURL=inline-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-object.js","sourceRoot":"","sources":["../../../../src/transport/generated/model/inline-object.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG
|
|
1
|
+
{"version":3,"file":"inline-object.js","sourceRoot":"","sources":["../../../../src/transport/generated/model/inline-object.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DefaultApi } from './generated';
|
|
2
|
+
import { IAuditLogTransport, IAuditLogCreationData } from './interface';
|
|
3
|
+
export declare class Transport implements IAuditLogTransport {
|
|
4
|
+
protected apiUrl: string;
|
|
5
|
+
api: DefaultApi;
|
|
6
|
+
constructor(apiUrl: string);
|
|
7
|
+
create(auditLogData: IAuditLogCreationData): Promise<void>;
|
|
8
|
+
}
|
|
@@ -20,15 +20,21 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
const generated_1 = require("./generated");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
class Transport {
|
|
24
|
+
constructor(apiUrl) {
|
|
25
|
+
this.apiUrl = apiUrl;
|
|
26
|
+
this.api = new generated_1.DefaultApi({
|
|
27
|
+
basePath: this.apiUrl,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
create(auditLogData) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const { account } = auditLogData, logDataWithoutAccount = __rest(auditLogData, ["account"]);
|
|
33
|
+
const dataToSend = Object.assign({}, logDataWithoutAccount, account);
|
|
34
|
+
console.log(dataToSend);
|
|
35
|
+
yield this.api.v1LogPost(dataToSend);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
|
-
exports.
|
|
39
|
+
exports.Transport = Transport;
|
|
34
40
|
//# sourceMappingURL=implementation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../src/transport/implementation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;
|
|
1
|
+
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../src/transport/implementation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AAGxC,MAAa,SAAS;IAGpB,YAAsB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAClC,IAAI,CAAC,GAAG,GAAG,IAAI,sBAAU,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,MAAM;SACtB,CAAC,CAAA;IACJ,CAAC;IAEK,MAAM,CAAC,YAAmC;;YAC9C,MAAM,EAAE,OAAO,KAA+B,YAAY,EAAzC,yDAAyC,CAAA;YAE1D,MAAM,UAAU,qBACX,qBAAqB,EACrB,OAAO,CACX,CAAA;YAED,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YAEvB,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QACtC,CAAC;KAAA;CACF;AArBD,8BAqBC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type
|
|
1
|
+
import { IAuditLogData } from '..';
|
|
2
|
+
export declare type IAuditLogCreationData = IAuditLogData & {
|
|
3
3
|
id: string;
|
|
4
4
|
timestamp: number;
|
|
5
|
+
environment: string;
|
|
5
6
|
};
|
|
7
|
+
export interface IAuditLogTransport {
|
|
8
|
+
create: (data: IAuditLogCreationData) => Promise<void>;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/audit-log",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-alpha7",
|
|
4
4
|
"description": "Library to handle audit logs at Payfit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"type:check": "tsc --noEmit",
|
|
8
9
|
"build": "rimraf dist && tsc",
|
|
9
10
|
"prepublish": "npm run build"
|
|
10
11
|
},
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AuditLogger } from '../src'
|
|
2
|
+
|
|
3
|
+
const logger = new AuditLogger({
|
|
4
|
+
apiUrl: 'http://localhost:8090',
|
|
5
|
+
environment: 'TEST-env',
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await logger.log({
|
|
10
|
+
event: 'signin',
|
|
11
|
+
namespace: 'auth',
|
|
12
|
+
service: 'auth',
|
|
13
|
+
payload: {
|
|
14
|
+
isTest: true,
|
|
15
|
+
},
|
|
16
|
+
account: {
|
|
17
|
+
isSystem: true,
|
|
18
|
+
},
|
|
19
|
+
scope: null,
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
main().catch(err => {
|
|
24
|
+
console.log('Error:', err)
|
|
25
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -1,35 +1,124 @@
|
|
|
1
1
|
import { v4 as uuidV4 } from 'uuid'
|
|
2
|
-
import
|
|
2
|
+
import { IAuditLogTransport } from './transport/interface'
|
|
3
|
+
import { Transport } from './transport/implementation'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Data to audit log.
|
|
7
|
+
*/
|
|
8
|
+
export interface IAuditLogData {
|
|
9
|
+
/**
|
|
10
|
+
* The data specific to the audit log.
|
|
11
|
+
* For example, if we add a bonus to an employee, it could contain the amount, the impacted employeeId, etc...
|
|
12
|
+
*/
|
|
6
13
|
payload?: object
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The buisness domain impacted.
|
|
17
|
+
* e.g documents, authentication, ...
|
|
18
|
+
*/
|
|
9
19
|
namespace: string
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The service name (tech).
|
|
23
|
+
* e.g files, payroll-api-v2, auth, ...
|
|
24
|
+
*/
|
|
10
25
|
service: string
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The name of the event.
|
|
29
|
+
* e.g. signIn, passwordUpdated, bonusAdded, ...
|
|
30
|
+
*/
|
|
11
31
|
event: string
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The data that describes who did perform the logged action.
|
|
35
|
+
*/
|
|
36
|
+
account: IAuditLogAuthData
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The scope of the audit log
|
|
40
|
+
*/
|
|
41
|
+
scope: IAuditLogScope
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Data used to indentify who performed an action
|
|
46
|
+
*/
|
|
47
|
+
export type IAuditLogAuthData =
|
|
48
|
+
| {
|
|
49
|
+
/**
|
|
50
|
+
* Tells if the action has been made during a siginAs
|
|
51
|
+
*/
|
|
52
|
+
isImpersonated?: boolean
|
|
53
|
+
|
|
54
|
+
// the "account" infos
|
|
55
|
+
holdingId?: string
|
|
56
|
+
companyId?: string
|
|
57
|
+
employeeId?: string
|
|
58
|
+
individualId: string
|
|
59
|
+
roleId?: string
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
countryCode?: string
|
|
65
|
+
/**
|
|
66
|
+
* The IP address of the user
|
|
67
|
+
*/
|
|
68
|
+
userIp?: string
|
|
69
|
+
/**
|
|
70
|
+
* The email address of the user
|
|
71
|
+
*/
|
|
72
|
+
email?: string
|
|
73
|
+
}
|
|
74
|
+
| {
|
|
75
|
+
/* Indicates that the action has been performed by the system */
|
|
76
|
+
isSystem: true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Data used to "scope" the audit log.
|
|
81
|
+
* Might be useful to retrieve all actions performed in a holding, a company, or on an employee.
|
|
82
|
+
*/
|
|
83
|
+
export type IAuditLogScope =
|
|
84
|
+
| {
|
|
85
|
+
holdingId: string
|
|
86
|
+
}
|
|
87
|
+
| {
|
|
88
|
+
companyId: string
|
|
89
|
+
employeeId?: string
|
|
90
|
+
}
|
|
91
|
+
| null
|
|
92
|
+
|
|
93
|
+
// warning: modifying this interface means probably make a breaking change to the SDK
|
|
94
|
+
export interface IAuditLogger {
|
|
95
|
+
log: (data: IAuditLogData) => Promise<void>
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface IAuditLoggerInitialization {
|
|
99
|
+
apiUrl: string
|
|
100
|
+
environment: string
|
|
20
101
|
}
|
|
21
102
|
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
const environment = process.env.ENVIRONMENT
|
|
25
|
-
const timestamp = new Date().getTime()
|
|
103
|
+
export class AuditLogger implements IAuditLogger {
|
|
104
|
+
private transport: IAuditLogTransport
|
|
26
105
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
id: uuid,
|
|
30
|
-
environment,
|
|
31
|
-
timestamp,
|
|
106
|
+
constructor(protected params: IAuditLoggerInitialization) {
|
|
107
|
+
this.transport = new Transport(params.apiUrl)
|
|
32
108
|
}
|
|
33
109
|
|
|
34
|
-
|
|
110
|
+
async log(params: IAuditLogData) {
|
|
111
|
+
const uuid = uuidV4()
|
|
112
|
+
const environment = this.params.environment
|
|
113
|
+
const timestamp = new Date().getTime()
|
|
114
|
+
|
|
115
|
+
const log = {
|
|
116
|
+
...params,
|
|
117
|
+
id: uuid,
|
|
118
|
+
environment,
|
|
119
|
+
timestamp,
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
await this.transport.create(log)
|
|
123
|
+
}
|
|
35
124
|
}
|
|
@@ -30,7 +30,7 @@ export interface InlineObject {
|
|
|
30
30
|
* @type {string}
|
|
31
31
|
* @memberof InlineObject
|
|
32
32
|
*/
|
|
33
|
-
countryCode
|
|
33
|
+
countryCode?: string;
|
|
34
34
|
/**
|
|
35
35
|
* Audit log event payload
|
|
36
36
|
* @type {object}
|
|
@@ -123,17 +123,4 @@ export interface InlineObject {
|
|
|
123
123
|
email?: string;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
/**
|
|
127
|
-
* @export
|
|
128
|
-
* @enum {string}
|
|
129
|
-
*/
|
|
130
|
-
export enum CountryCodeEnum {
|
|
131
|
-
FR = 'fr',
|
|
132
|
-
DE = 'de',
|
|
133
|
-
IT = 'it',
|
|
134
|
-
ES = 'es',
|
|
135
|
-
GB = 'gb'
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
126
|
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { DefaultApi } from './generated'
|
|
2
|
-
import {
|
|
3
|
-
import { AuditLogCreationData } from './interface'
|
|
2
|
+
import { IAuditLogTransport, IAuditLogCreationData } from './interface'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})
|
|
4
|
+
export class Transport implements IAuditLogTransport {
|
|
5
|
+
api: DefaultApi
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...data,
|
|
14
|
-
countryCode: countryCode as CountryCodeEnum,
|
|
15
|
-
payload,
|
|
7
|
+
constructor(protected apiUrl: string) {
|
|
8
|
+
this.api = new DefaultApi({
|
|
9
|
+
basePath: this.apiUrl,
|
|
10
|
+
})
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
async create(auditLogData: IAuditLogCreationData) {
|
|
14
|
+
const { account, ...logDataWithoutAccount } = auditLogData
|
|
15
|
+
|
|
16
|
+
const dataToSend = {
|
|
17
|
+
...logDataWithoutAccount,
|
|
18
|
+
...account,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
console.log(dataToSend)
|
|
22
|
+
|
|
23
|
+
await this.api.v1LogPost(dataToSend)
|
|
24
|
+
}
|
|
19
25
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAuditLogData } from '..'
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type IAuditLogCreationData = IAuditLogData & {
|
|
4
4
|
id: string
|
|
5
5
|
timestamp: number
|
|
6
|
+
environment: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IAuditLogTransport {
|
|
10
|
+
create: (data: IAuditLogCreationData) => Promise<void>
|
|
6
11
|
}
|