@payfit/audit-log 1.0.0-rc.98 → 1.0.0
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/.prettierrc +5 -0
- package/README.md +8 -10
- package/dist/index.d.ts +8 -27
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -0
- package/dist/transport/generated/api/default-api.d.ts +7 -7
- package/dist/transport/generated/api/default-api.js +131 -0
- package/dist/transport/generated/api/default-api.js.map +1 -0
- package/dist/transport/generated/api.js +19 -0
- package/dist/transport/generated/api.js.map +1 -0
- package/dist/transport/generated/base.d.ts +2 -2
- package/dist/transport/generated/base.js +63 -0
- package/dist/transport/generated/base.js.map +1 -0
- package/dist/transport/generated/configuration.d.ts +4 -24
- package/dist/transport/generated/configuration.js +26 -0
- package/dist/transport/generated/configuration.js.map +1 -0
- package/dist/transport/generated/index.d.ts +0 -1
- package/dist/transport/generated/index.js +20 -0
- package/dist/transport/generated/index.js.map +1 -0
- package/dist/transport/generated/model/index.js +3 -0
- package/dist/transport/generated/model/index.js.map +1 -0
- package/dist/transport/generated/model/inline-object.d.ts +18 -36
- package/dist/transport/generated/model/inline-object.js +15 -0
- package/dist/transport/generated/model/inline-object.js.map +1 -0
- package/dist/transport/implementation.d.ts +4 -4
- package/dist/transport/implementation.js +39 -0
- package/dist/transport/implementation.js.map +1 -0
- package/dist/transport/interface.d.ts +3 -18
- package/dist/transport/interface.js +3 -0
- package/dist/transport/interface.js.map +1 -0
- package/openapi-codegen-config.yml +6 -0
- package/package.json +19 -46
- package/playground/index.ts +29 -0
- package/src/index.ts +120 -0
- package/src/transport/generated/.openapi-generator/VERSION +1 -0
- package/src/transport/generated/.openapi-generator-ignore +23 -0
- package/src/transport/generated/api/default-api.ts +131 -0
- package/src/transport/generated/api.ts +17 -0
- package/src/transport/generated/base.ts +70 -0
- package/src/transport/generated/configuration.ts +75 -0
- package/src/transport/generated/git_push.sh +58 -0
- package/src/transport/generated/index.ts +16 -0
- package/src/transport/generated/model/index.ts +1 -0
- package/src/transport/generated/model/inline-object.ts +126 -0
- package/src/transport/implementation.ts +23 -0
- package/src/transport/interface.ts +12 -0
- package/tsconfig.json +25 -0
- package/tslint.json +12 -0
- package/dist/index.mjs +0 -149
- package/dist/playground.d.ts +0 -1
- package/dist/transport/generated/common.d.ts +0 -65
|
@@ -20,119 +20,101 @@ export interface InlineObject {
|
|
|
20
20
|
* @type {string}
|
|
21
21
|
* @memberof InlineObject
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
id: string;
|
|
24
24
|
/**
|
|
25
25
|
* Audit log event country code
|
|
26
26
|
* @type {string}
|
|
27
27
|
* @memberof InlineObject
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
countryCode?: string;
|
|
30
30
|
/**
|
|
31
31
|
* Audit log event payload
|
|
32
32
|
* @type {object}
|
|
33
33
|
* @memberof InlineObject
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
payload?: object;
|
|
36
36
|
/**
|
|
37
37
|
* id of the payfiter who performed the audit log action, if signed as.
|
|
38
38
|
* @type {string}
|
|
39
39
|
* @memberof InlineObject
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
internalId?: string;
|
|
42
42
|
/**
|
|
43
43
|
* Tells whether the logged action has been made by the system
|
|
44
44
|
* @type {boolean}
|
|
45
45
|
* @memberof InlineObject
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
isSystem?: boolean;
|
|
48
48
|
/**
|
|
49
49
|
* Audit log event namespace (business related)
|
|
50
50
|
* @type {string}
|
|
51
51
|
* @memberof InlineObject
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
namespace: string;
|
|
54
54
|
/**
|
|
55
55
|
* Audit log event namespace (technical related)
|
|
56
56
|
* @type {string}
|
|
57
57
|
* @memberof InlineObject
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
service: string;
|
|
60
60
|
/**
|
|
61
61
|
* Audit log event type
|
|
62
62
|
* @type {string}
|
|
63
63
|
* @memberof InlineObject
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
event?: string;
|
|
66
66
|
/**
|
|
67
|
-
* Audit log
|
|
67
|
+
* Audit log event environment
|
|
68
68
|
* @type {string}
|
|
69
69
|
* @memberof InlineObject
|
|
70
70
|
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Audit log event environment, only required when in todd context
|
|
74
|
-
* @type {string}
|
|
75
|
-
* @memberof InlineObject
|
|
76
|
-
*/
|
|
77
|
-
'environment'?: string;
|
|
71
|
+
environment?: string;
|
|
78
72
|
/**
|
|
79
73
|
* holdingId of the account performing the event
|
|
80
74
|
* @type {string}
|
|
81
75
|
* @memberof InlineObject
|
|
82
76
|
*/
|
|
83
|
-
|
|
77
|
+
holdingId?: string;
|
|
84
78
|
/**
|
|
85
79
|
* companyId of the account performing the event
|
|
86
80
|
* @type {string}
|
|
87
81
|
* @memberof InlineObject
|
|
88
82
|
*/
|
|
89
|
-
|
|
83
|
+
companyId?: string;
|
|
90
84
|
/**
|
|
91
85
|
* employeeId of the account performing the event
|
|
92
86
|
* @type {string}
|
|
93
87
|
* @memberof InlineObject
|
|
94
88
|
*/
|
|
95
|
-
|
|
89
|
+
employeeId?: string;
|
|
96
90
|
/**
|
|
97
91
|
* individualId of the account performing the event
|
|
98
92
|
* @type {string}
|
|
99
93
|
* @memberof InlineObject
|
|
100
94
|
*/
|
|
101
|
-
|
|
95
|
+
individualId?: string;
|
|
102
96
|
/**
|
|
103
97
|
* roleId of the account performing the event
|
|
104
98
|
* @type {string}
|
|
105
99
|
* @memberof InlineObject
|
|
106
100
|
*/
|
|
107
|
-
|
|
101
|
+
roleId?: string;
|
|
108
102
|
/**
|
|
109
103
|
* userIp of the account performing the event
|
|
110
104
|
* @type {string}
|
|
111
105
|
* @memberof InlineObject
|
|
112
106
|
*/
|
|
113
|
-
|
|
107
|
+
userIp?: string;
|
|
114
108
|
/**
|
|
115
109
|
* specialRole of the account performing the event
|
|
116
110
|
* @type {string}
|
|
117
111
|
* @memberof InlineObject
|
|
118
112
|
*/
|
|
119
|
-
|
|
113
|
+
specialRole?: string;
|
|
120
114
|
/**
|
|
121
115
|
* email of the account performing the event
|
|
122
116
|
* @type {string}
|
|
123
117
|
* @memberof InlineObject
|
|
124
118
|
*/
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Audit log event scope
|
|
128
|
-
* @type {object}
|
|
129
|
-
* @memberof InlineObject
|
|
130
|
-
*/
|
|
131
|
-
'scope'?: object;
|
|
132
|
-
/**
|
|
133
|
-
* Audit log event timestamp unix format
|
|
134
|
-
* @type {number}
|
|
135
|
-
* @memberof InlineObject
|
|
136
|
-
*/
|
|
137
|
-
'timestamp': number;
|
|
119
|
+
email?: string;
|
|
138
120
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// tslint:disable
|
|
3
|
+
/**
|
|
4
|
+
* Audit Logs
|
|
5
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
* Contact: damian.bursztyn@payfit.com
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
//# sourceMappingURL=inline-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-object.js","sourceRoot":"","sources":["../../../../src/transport/generated/model/inline-object.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IAuditLogTransport } from './interface';
|
|
1
|
+
import { DefaultApi } from './generated';
|
|
2
|
+
import { IAuditLogTransport, IAuditLogCreationData } from './interface';
|
|
3
3
|
export declare class Transport implements IAuditLogTransport {
|
|
4
4
|
protected apiUrl: string;
|
|
5
|
-
|
|
5
|
+
api: DefaultApi;
|
|
6
6
|
constructor(apiUrl: string);
|
|
7
|
-
create(auditLogData:
|
|
7
|
+
create(auditLogData: IAuditLogCreationData): Promise<void>;
|
|
8
8
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const generated_1 = require("./generated");
|
|
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
|
+
yield this.api.v1LogPost(dataToSend);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Transport = Transport;
|
|
39
|
+
//# sourceMappingURL=implementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QACtC,CAAC;KAAA;CACF;AAnBD,8BAmBC"}
|
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { IAuditLogData } from '..';
|
|
2
|
+
export declare type IAuditLogCreationData = IAuditLogData & {
|
|
2
3
|
id: string;
|
|
3
4
|
timestamp: number;
|
|
4
5
|
environment: string;
|
|
5
6
|
service: string;
|
|
6
|
-
|
|
7
|
-
countryCode?: string;
|
|
8
|
-
payload?: Record<string, unknown>;
|
|
9
|
-
internalId?: string;
|
|
10
|
-
isSystem?: boolean;
|
|
11
|
-
namespace: string;
|
|
12
|
-
event: string;
|
|
13
|
-
target: string;
|
|
14
|
-
holdingId?: string;
|
|
15
|
-
companyId?: string;
|
|
16
|
-
employeeId?: string;
|
|
17
|
-
individualId?: string;
|
|
18
|
-
roleId?: string;
|
|
19
|
-
userIp?: string;
|
|
20
|
-
specialRole?: string;
|
|
21
|
-
email?: string;
|
|
22
|
-
}
|
|
7
|
+
};
|
|
23
8
|
export interface IAuditLogTransport {
|
|
24
9
|
create: (data: IAuditLogCreationData) => Promise<void>;
|
|
25
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/transport/interface.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,58 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/audit-log",
|
|
3
|
-
"version": "1.0.0
|
|
4
|
-
"repository": {
|
|
5
|
-
"type": "git",
|
|
6
|
-
"url": "https://github.com/PayFit/audit-logs.git",
|
|
7
|
-
"directory": "sdk"
|
|
8
|
-
},
|
|
3
|
+
"version": "1.0.0",
|
|
9
4
|
"description": "Library to handle audit logs at Payfit",
|
|
10
5
|
"main": "dist/index.js",
|
|
11
|
-
"module": "dist/index.mjs",
|
|
12
|
-
"types": "dist/index.d.ts",
|
|
13
6
|
"scripts": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"start:playground": "ts-node
|
|
19
|
-
"format:check": "prettier --check .",
|
|
20
|
-
"format:fix": "prettier --write .",
|
|
21
|
-
"release": "semantic-release --noCi"
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"type:check": "tsc --noEmit",
|
|
9
|
+
"build": "rimraf dist && tsc",
|
|
10
|
+
"prepublish": "npm run build",
|
|
11
|
+
"start:playground": "ts-node playground/index.ts"
|
|
22
12
|
},
|
|
23
13
|
"author": "",
|
|
24
14
|
"license": "ISC",
|
|
25
15
|
"dependencies": {
|
|
26
|
-
"axios": "
|
|
27
|
-
"lodash": "
|
|
28
|
-
"uuid": "
|
|
16
|
+
"axios": "0.19.2",
|
|
17
|
+
"lodash": "4.17.15",
|
|
18
|
+
"uuid": "7.0.0"
|
|
29
19
|
},
|
|
30
20
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "6.7.0",
|
|
42
|
-
"builtin-modules": "3.3.0",
|
|
43
|
-
"eslint": "8.49.0",
|
|
44
|
-
"prettier": "3.0.3",
|
|
45
|
-
"rimraf": "5.0.1",
|
|
46
|
-
"semantic-release": "20.1.3",
|
|
47
|
-
"ts-node": "10.9.1",
|
|
48
|
-
"typescript": "5.2.2",
|
|
49
|
-
"vite": "4.4.9"
|
|
50
|
-
},
|
|
51
|
-
"peerDependencies": {},
|
|
52
|
-
"publishConfig": {
|
|
53
|
-
"registry": "https://registry.npmjs.org/"
|
|
54
|
-
},
|
|
55
|
-
"files": [
|
|
56
|
-
"dist"
|
|
57
|
-
]
|
|
21
|
+
"@types/lodash": "4.14.149",
|
|
22
|
+
"@types/uuid": "3.4.7",
|
|
23
|
+
"prettier": "1.18.2",
|
|
24
|
+
"rimraf": "2.6.3",
|
|
25
|
+
"ts-node": "8.3.0",
|
|
26
|
+
"ts-node-dev": "1.0.0-pre.40",
|
|
27
|
+
"tslint": "5.18.0",
|
|
28
|
+
"tslint-config-prettier": "1.18.0",
|
|
29
|
+
"typescript": "3.5.3"
|
|
30
|
+
}
|
|
58
31
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuditLogger } from '../src'
|
|
2
|
+
|
|
3
|
+
const logger = new AuditLogger({
|
|
4
|
+
apiUrl: 'http://localhost:8090',
|
|
5
|
+
environment: 'TEST-env',
|
|
6
|
+
service: 'auth',
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await logger.log({
|
|
11
|
+
event: 'signin',
|
|
12
|
+
namespace: 'auth',
|
|
13
|
+
payload: {
|
|
14
|
+
isTest: true,
|
|
15
|
+
},
|
|
16
|
+
account: {
|
|
17
|
+
internalId: 'an internal id',
|
|
18
|
+
individualId: 'an invidiaul id',
|
|
19
|
+
},
|
|
20
|
+
scope: {
|
|
21
|
+
employeeId: 'an employee id',
|
|
22
|
+
companyId: 'a company id',
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main().catch(err => {
|
|
28
|
+
console.log('Error:', err)
|
|
29
|
+
})
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { v4 as uuidV4 } from 'uuid'
|
|
2
|
+
import { IAuditLogTransport } from './transport/interface'
|
|
3
|
+
import { Transport } from './transport/implementation'
|
|
4
|
+
|
|
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
|
+
*/
|
|
13
|
+
payload?: object
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The buisness domain impacted.
|
|
17
|
+
* e.g documents, authentication, ...
|
|
18
|
+
*/
|
|
19
|
+
namespace: string
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The name of the event.
|
|
23
|
+
* e.g. signIn, passwordUpdated, bonusAdded, ...
|
|
24
|
+
*/
|
|
25
|
+
event: string
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The data that describes who did perform the logged action.
|
|
29
|
+
*/
|
|
30
|
+
account: IAuditLogAuthData
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The scope of the audit log
|
|
34
|
+
*/
|
|
35
|
+
scope: IAuditLogScope
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Data used to indentify who performed an action
|
|
40
|
+
*/
|
|
41
|
+
export type IAuditLogAuthData =
|
|
42
|
+
| {
|
|
43
|
+
/**
|
|
44
|
+
* The id of the payfiter that did the action if it has been made during a siginAs
|
|
45
|
+
*/
|
|
46
|
+
internalId?: string
|
|
47
|
+
|
|
48
|
+
// the "account" infos
|
|
49
|
+
holdingId?: string
|
|
50
|
+
companyId?: string
|
|
51
|
+
employeeId?: string
|
|
52
|
+
individualId: string
|
|
53
|
+
roleId?: string
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
countryCode?: string
|
|
59
|
+
/**
|
|
60
|
+
* The IP address of the user
|
|
61
|
+
*/
|
|
62
|
+
userIp?: string
|
|
63
|
+
/**
|
|
64
|
+
* The email address of the user
|
|
65
|
+
*/
|
|
66
|
+
email?: string
|
|
67
|
+
}
|
|
68
|
+
| {
|
|
69
|
+
/* Indicates that the action has been performed by the system */
|
|
70
|
+
isSystem: true
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Data used to "scope" the audit log.
|
|
75
|
+
* Might be useful to retrieve all actions performed in a holding, a company, or on an employee.
|
|
76
|
+
*/
|
|
77
|
+
export type IAuditLogScope =
|
|
78
|
+
| {
|
|
79
|
+
holdingId: string
|
|
80
|
+
}
|
|
81
|
+
| {
|
|
82
|
+
companyId: string
|
|
83
|
+
employeeId?: string
|
|
84
|
+
}
|
|
85
|
+
| null
|
|
86
|
+
|
|
87
|
+
// warning: modifying this interface means probably make a breaking change to the SDK
|
|
88
|
+
export interface IAuditLogger {
|
|
89
|
+
log: (data: IAuditLogData) => Promise<void>
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface IAuditLoggerInitialization {
|
|
93
|
+
apiUrl: string
|
|
94
|
+
environment: string
|
|
95
|
+
service: string
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class AuditLogger implements IAuditLogger {
|
|
99
|
+
private transport: IAuditLogTransport
|
|
100
|
+
|
|
101
|
+
constructor(protected params: IAuditLoggerInitialization) {
|
|
102
|
+
this.transport = new Transport(params.apiUrl)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async log(data: IAuditLogData) {
|
|
106
|
+
const uuid = uuidV4()
|
|
107
|
+
const { environment, service } = this.params
|
|
108
|
+
const timestamp = new Date().getTime()
|
|
109
|
+
|
|
110
|
+
const log = {
|
|
111
|
+
...data,
|
|
112
|
+
service,
|
|
113
|
+
id: uuid,
|
|
114
|
+
environment,
|
|
115
|
+
timestamp,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await this.transport.create(log)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.2.3
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# OpenAPI Generator Ignore
|
|
2
|
+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
|
3
|
+
|
|
4
|
+
# Use this file to prevent files from being overwritten by the generator.
|
|
5
|
+
# The patterns follow closely to .gitignore or .dockerignore.
|
|
6
|
+
|
|
7
|
+
# As an example, the C# client generator defines ApiClient.cs.
|
|
8
|
+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
|
9
|
+
#ApiClient.cs
|
|
10
|
+
|
|
11
|
+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
|
12
|
+
#foo/*/qux
|
|
13
|
+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
|
14
|
+
|
|
15
|
+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
|
16
|
+
#foo/**/qux
|
|
17
|
+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
|
18
|
+
|
|
19
|
+
# You can also negate patterns with an exclamation (!).
|
|
20
|
+
# For example, you can ignore all files in a docs folder with the file extension .md:
|
|
21
|
+
#docs/*.md
|
|
22
|
+
# Then explicitly reverse the ignore rule for a single file:
|
|
23
|
+
#!docs/README.md
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// tslint:disable
|
|
2
|
+
/**
|
|
3
|
+
* Audit Logs
|
|
4
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
*
|
|
6
|
+
* The version of the OpenAPI document: 1.0.0
|
|
7
|
+
* Contact: damian.bursztyn@payfit.com
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
10
|
+
* https://openapi-generator.tech
|
|
11
|
+
* Do not edit the class manually.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
import * as globalImportUrl from 'url';
|
|
16
|
+
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
|
|
17
|
+
import { Configuration } from '../configuration';
|
|
18
|
+
// Some imports not used depending on template conditions
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
|
|
21
|
+
|
|
22
|
+
import { InlineObject } from '../model';
|
|
23
|
+
/**
|
|
24
|
+
* DefaultApi - axios parameter creator
|
|
25
|
+
* @export
|
|
26
|
+
*/
|
|
27
|
+
export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) {
|
|
28
|
+
return {
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @summary Creates Audit Log event
|
|
32
|
+
* @param {InlineObject} inlineObject
|
|
33
|
+
* @param {*} [options] Override http request option.
|
|
34
|
+
* @throws {RequiredError}
|
|
35
|
+
*/
|
|
36
|
+
v1LogPost(inlineObject: InlineObject, options: any = {}): RequestArgs {
|
|
37
|
+
// verify required parameter 'inlineObject' is not null or undefined
|
|
38
|
+
if (inlineObject === null || inlineObject === undefined) {
|
|
39
|
+
throw new RequiredError('inlineObject','Required parameter inlineObject was null or undefined when calling v1LogPost.');
|
|
40
|
+
}
|
|
41
|
+
const localVarPath = `/v1/log`;
|
|
42
|
+
const localVarUrlObj = globalImportUrl.parse(localVarPath, true);
|
|
43
|
+
let baseOptions;
|
|
44
|
+
if (configuration) {
|
|
45
|
+
baseOptions = configuration.baseOptions;
|
|
46
|
+
}
|
|
47
|
+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
|
|
48
|
+
const localVarHeaderParameter = {} as any;
|
|
49
|
+
const localVarQueryParameter = {} as any;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
54
|
+
|
|
55
|
+
localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query};
|
|
56
|
+
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
|
57
|
+
delete localVarUrlObj.search;
|
|
58
|
+
localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};
|
|
59
|
+
const needsSerialization = (typeof inlineObject !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
|
60
|
+
localVarRequestOptions.data = needsSerialization ? JSON.stringify(inlineObject !== undefined ? inlineObject : {}) : (inlineObject || "");
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
url: globalImportUrl.format(localVarUrlObj),
|
|
64
|
+
options: localVarRequestOptions,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* DefaultApi - functional programming interface
|
|
72
|
+
* @export
|
|
73
|
+
*/
|
|
74
|
+
export const DefaultApiFp = function(configuration?: Configuration) {
|
|
75
|
+
return {
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @summary Creates Audit Log event
|
|
79
|
+
* @param {InlineObject} inlineObject
|
|
80
|
+
* @param {*} [options] Override http request option.
|
|
81
|
+
* @throws {RequiredError}
|
|
82
|
+
*/
|
|
83
|
+
v1LogPost(inlineObject: InlineObject, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<void> {
|
|
84
|
+
const localVarAxiosArgs = DefaultApiAxiosParamCreator(configuration).v1LogPost(inlineObject, options);
|
|
85
|
+
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
86
|
+
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
|
87
|
+
return axios.request(axiosRequestArgs);
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* DefaultApi - factory interface
|
|
95
|
+
* @export
|
|
96
|
+
*/
|
|
97
|
+
export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
|
98
|
+
return {
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
* @summary Creates Audit Log event
|
|
102
|
+
* @param {InlineObject} inlineObject
|
|
103
|
+
* @param {*} [options] Override http request option.
|
|
104
|
+
* @throws {RequiredError}
|
|
105
|
+
*/
|
|
106
|
+
v1LogPost(inlineObject: InlineObject, options?: any): AxiosPromise<void> {
|
|
107
|
+
return DefaultApiFp(configuration).v1LogPost(inlineObject, options)(axios, basePath);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* DefaultApi - object-oriented interface
|
|
114
|
+
* @export
|
|
115
|
+
* @class DefaultApi
|
|
116
|
+
* @extends {BaseAPI}
|
|
117
|
+
*/
|
|
118
|
+
export class DefaultApi extends BaseAPI {
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @summary Creates Audit Log event
|
|
122
|
+
* @param {InlineObject} inlineObject
|
|
123
|
+
* @param {*} [options] Override http request option.
|
|
124
|
+
* @throws {RequiredError}
|
|
125
|
+
* @memberof DefaultApi
|
|
126
|
+
*/
|
|
127
|
+
public v1LogPost(inlineObject: InlineObject, options?: any) {
|
|
128
|
+
return DefaultApiFp(this.configuration).v1LogPost(inlineObject, options)(this.axios, this.basePath);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// tslint:disable
|
|
2
|
+
/**
|
|
3
|
+
* Audit Logs
|
|
4
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
*
|
|
6
|
+
* The version of the OpenAPI document: 1.0.0
|
|
7
|
+
* Contact: damian.bursztyn@payfit.com
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
10
|
+
* https://openapi-generator.tech
|
|
11
|
+
* Do not edit the class manually.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export * from './api/default-api';
|
|
17
|
+
|