@payfit/audit-log 1.0.2 → 1.0.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/CHANGELOG.md +9 -0
- package/README.md +2 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/transport/generated/api/default-api.js +4 -4
- package/dist/transport/generated/api/default-api.js.map +1 -1
- package/dist/transport/generated/model/inline-object.d.ts +6 -0
- package/dist/transport/implementation.d.ts +3 -2
- package/dist/transport/implementation.js +13 -15
- package/dist/transport/implementation.js.map +1 -1
- package/dist/transport/interface.d.ts +17 -2
- package/package.json +2 -2
- package/playground/index.ts +1 -1
- package/src/index.ts +6 -1
- package/src/transport/generated/model/inline-object.ts +6 -0
- package/src/transport/implementation.ts +12 -8
- package/src/transport/interface.ts +17 -1
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -68,6 +68,8 @@ export declare type IAuditLogScope = {
|
|
|
68
68
|
} | {
|
|
69
69
|
companyId: string;
|
|
70
70
|
employeeId?: string;
|
|
71
|
+
} | {
|
|
72
|
+
individualId: string;
|
|
71
73
|
} | null;
|
|
72
74
|
export interface IAuditLogger {
|
|
73
75
|
log: (data: IAuditLogData) => Promise<void>;
|
|
@@ -81,5 +83,5 @@ export declare class AuditLogger implements IAuditLogger {
|
|
|
81
83
|
protected params: IAuditLoggerInitialization;
|
|
82
84
|
private transport;
|
|
83
85
|
constructor(params: IAuditLoggerInitialization);
|
|
84
|
-
log(data: IAuditLogData): Promise<void>;
|
|
86
|
+
log({ scope, account, ...data }: IAuditLogData): Promise<void>;
|
|
85
87
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
5
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
6
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
10
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
23
|
const uuid_1 = require("uuid");
|
|
12
24
|
const implementation_1 = require("./transport/implementation");
|
|
@@ -15,13 +27,14 @@ class AuditLogger {
|
|
|
15
27
|
this.params = params;
|
|
16
28
|
this.transport = new implementation_1.Transport(params.apiUrl);
|
|
17
29
|
}
|
|
18
|
-
log(
|
|
30
|
+
log(_a) {
|
|
31
|
+
var { scope, account } = _a, data = __rest(_a, ["scope", "account"]);
|
|
19
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
33
|
const uuid = uuid_1.v4();
|
|
21
34
|
const { environment, service } = this.params;
|
|
22
35
|
const timestamp = new Date().getTime();
|
|
23
|
-
const log = Object.assign({}, data, { service, id: uuid, environment,
|
|
24
|
-
timestamp });
|
|
36
|
+
const log = Object.assign(Object.assign(Object.assign(Object.assign({}, data), account), { service, id: uuid, environment,
|
|
37
|
+
timestamp }), (scope && { scope }));
|
|
25
38
|
yield this.transport.create(log);
|
|
26
39
|
});
|
|
27
40
|
}
|
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;AAwGtD,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,EAA0C;YAA1C,EAAE,KAAK,EAAE,OAAO,OAA0B,EAAxB,uCAAO;;YACjC,MAAM,IAAI,GAAG,SAAM,EAAE,CAAA;YACrB,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;YAC5C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;YAEtC,MAAM,GAAG,+DACJ,IAAI,GACJ,OAAO,KACV,OAAO,EACP,EAAE,EAAE,IAAI,EACR,WAAW;gBACX,SAAS,KACN,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,CAAC,CACxB,CAAA;YAED,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;;KACjC;CACF;AAxBD,kCAwBC"}
|
|
@@ -51,14 +51,14 @@ exports.DefaultApiAxiosParamCreator = function (configuration) {
|
|
|
51
51
|
if (configuration) {
|
|
52
52
|
baseOptions = configuration.baseOptions;
|
|
53
53
|
}
|
|
54
|
-
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
|
|
54
|
+
const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
|
|
55
55
|
const localVarHeaderParameter = {};
|
|
56
56
|
const localVarQueryParameter = {};
|
|
57
57
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
58
|
-
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
|
|
58
|
+
localVarUrlObj.query = Object.assign(Object.assign(Object.assign({}, localVarUrlObj.query), localVarQueryParameter), options.query);
|
|
59
59
|
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
|
60
60
|
delete localVarUrlObj.search;
|
|
61
|
-
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
|
|
61
|
+
localVarRequestOptions.headers = Object.assign(Object.assign({}, localVarHeaderParameter), options.headers);
|
|
62
62
|
const needsSerialization = (typeof inlineObject !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
|
63
63
|
localVarRequestOptions.data = needsSerialization ? JSON.stringify(inlineObject !== undefined ? inlineObject : {}) : (inlineObject || "");
|
|
64
64
|
return {
|
|
@@ -84,7 +84,7 @@ exports.DefaultApiFp = function (configuration) {
|
|
|
84
84
|
v1LogPost(inlineObject, options) {
|
|
85
85
|
const localVarAxiosArgs = exports.DefaultApiAxiosParamCreator(configuration).v1LogPost(inlineObject, options);
|
|
86
86
|
return (axios = axios_1.default, basePath = base_1.BASE_PATH) => {
|
|
87
|
-
const axiosRequestArgs = Object.assign({}, localVarAxiosArgs.options, { url: basePath + localVarAxiosArgs.url });
|
|
87
|
+
const axiosRequestArgs = Object.assign(Object.assign({}, localVarAxiosArgs.options), { url: basePath + localVarAxiosArgs.url });
|
|
88
88
|
return axios.request(axiosRequestArgs);
|
|
89
89
|
};
|
|
90
90
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-api.js","sourceRoot":"","sources":["../../../../src/transport/generated/api/default-api.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG;;;;;;;;;;;;AAGH,qDAAuC;AACvC,kDAAiE;AAEjE,yDAAyD;AACzD,aAAa;AACb,kCAA6F;AAG7F;;;GAGG;AACU,QAAA,2BAA2B,GAAG,UAAU,aAA6B;IAC9E,OAAO;QACH;;;;;;WAMG;QACH,SAAS,CAAC,YAA0B,EAAE,UAAe,EAAE;YACnD,oEAAoE;YACpE,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,SAAS,EAAE;gBACrD,MAAM,IAAI,oBAAa,CAAC,cAAc,EAAC,+EAA+E,CAAC,CAAC;aAC3H;YACD,MAAM,YAAY,GAAG,SAAS,CAAC;YAC/B,MAAM,cAAc,GAAG,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YACjE,IAAI,WAAW,CAAC;YAChB,IAAI,aAAa,EAAE;gBACf,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;aAC3C;YACD,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"default-api.js","sourceRoot":"","sources":["../../../../src/transport/generated/api/default-api.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DefaultApi } from './generated';
|
|
2
|
-
import {
|
|
2
|
+
import { InlineObject } from './generated/model';
|
|
3
|
+
import { IAuditLogTransport } from './interface';
|
|
3
4
|
export declare class Transport implements IAuditLogTransport {
|
|
4
5
|
protected apiUrl: string;
|
|
5
6
|
api: DefaultApi;
|
|
6
7
|
constructor(apiUrl: string);
|
|
7
|
-
create(auditLogData:
|
|
8
|
+
create(auditLogData: InlineObject): Promise<void>;
|
|
8
9
|
}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
5
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
6
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
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
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
12
|
const generated_1 = require("./generated");
|
|
23
13
|
class Transport {
|
|
@@ -28,10 +18,18 @@ class Transport {
|
|
|
28
18
|
});
|
|
29
19
|
}
|
|
30
20
|
create(auditLogData) {
|
|
21
|
+
var _a;
|
|
31
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
try {
|
|
24
|
+
yield this.api.v1LogPost(auditLogData);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
if (!err.isAxiosError) {
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
const message = ((_a = err.response) === null || _a === void 0 ? void 0 : _a.data) || err.message;
|
|
31
|
+
throw new Error(message);
|
|
32
|
+
}
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../src/transport/implementation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../src/transport/implementation.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAAwC;AAKxC,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,YAA0B;;;YACrC,IAAI;gBACF,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;aACvC;YAAC,OAAM,GAAG,EAAE;gBACX,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE;oBACrB,MAAM,GAAG,CAAA;iBACV;gBAED,MAAM,OAAO,GAAG,OAAA,GAAG,CAAC,QAAQ,0CAAE,IAAI,KAAI,GAAG,CAAC,OAAO,CAAA;gBACjD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;aACzB;;KACF;CACF;AArBD,8BAqBC"}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type IAuditLogCreationData = IAuditLogData & {
|
|
1
|
+
export declare type IAuditLogCreationData = {
|
|
3
2
|
id: string;
|
|
4
3
|
timestamp: number;
|
|
5
4
|
environment: string;
|
|
6
5
|
service: string;
|
|
6
|
+
scope?: object;
|
|
7
|
+
countryCode?: string;
|
|
8
|
+
payload?: object;
|
|
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;
|
|
7
22
|
};
|
|
8
23
|
export interface IAuditLogTransport {
|
|
9
24
|
create: (data: IAuditLogCreationData) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/audit-log",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Library to handle audit logs at Payfit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"ts-node-dev": "1.0.0-pre.40",
|
|
27
27
|
"tslint": "5.18.0",
|
|
28
28
|
"tslint-config-prettier": "1.18.0",
|
|
29
|
-
"typescript": "3.
|
|
29
|
+
"typescript": "3.8.3"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/playground/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -88,6 +88,9 @@ export type IAuditLogScope =
|
|
|
88
88
|
companyId: string
|
|
89
89
|
employeeId?: string
|
|
90
90
|
}
|
|
91
|
+
| {
|
|
92
|
+
individualId: string
|
|
93
|
+
}
|
|
91
94
|
| null
|
|
92
95
|
|
|
93
96
|
// warning: modifying this interface means probably make a breaking change to the SDK
|
|
@@ -108,17 +111,19 @@ export class AuditLogger implements IAuditLogger {
|
|
|
108
111
|
this.transport = new Transport(params.apiUrl)
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
async log(data: IAuditLogData) {
|
|
114
|
+
async log({ scope, account, ...data }: IAuditLogData) {
|
|
112
115
|
const uuid = uuidV4()
|
|
113
116
|
const { environment, service } = this.params
|
|
114
117
|
const timestamp = new Date().getTime()
|
|
115
118
|
|
|
116
119
|
const log = {
|
|
117
120
|
...data,
|
|
121
|
+
...account,
|
|
118
122
|
service,
|
|
119
123
|
id: uuid,
|
|
120
124
|
environment,
|
|
121
125
|
timestamp,
|
|
126
|
+
...(scope && { scope }),
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
await this.transport.create(log)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DefaultApi } from './generated'
|
|
2
|
-
import {
|
|
2
|
+
import { InlineObject } from './generated/model'
|
|
3
|
+
|
|
4
|
+
import { IAuditLogTransport } from './interface'
|
|
3
5
|
|
|
4
6
|
export class Transport implements IAuditLogTransport {
|
|
5
7
|
api: DefaultApi
|
|
@@ -10,14 +12,16 @@ export class Transport implements IAuditLogTransport {
|
|
|
10
12
|
})
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
async create(auditLogData:
|
|
14
|
-
|
|
15
|
+
async create(auditLogData: InlineObject) {
|
|
16
|
+
try {
|
|
17
|
+
await this.api.v1LogPost(auditLogData)
|
|
18
|
+
} catch(err) {
|
|
19
|
+
if (!err.isAxiosError) {
|
|
20
|
+
throw err
|
|
21
|
+
}
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...account,
|
|
23
|
+
const message = err.response?.data || err.message
|
|
24
|
+
throw new Error(message)
|
|
19
25
|
}
|
|
20
|
-
|
|
21
|
-
await this.api.v1LogPost(dataToSend)
|
|
22
26
|
}
|
|
23
27
|
}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import { IAuditLogData } from '..'
|
|
2
2
|
|
|
3
|
-
export type IAuditLogCreationData =
|
|
3
|
+
export type IAuditLogCreationData = {
|
|
4
4
|
id: string
|
|
5
5
|
timestamp: number
|
|
6
6
|
environment: string
|
|
7
7
|
service: string
|
|
8
|
+
scope?: object
|
|
9
|
+
countryCode?: string
|
|
10
|
+
payload?: object
|
|
11
|
+
internalId?: string
|
|
12
|
+
isSystem?: boolean
|
|
13
|
+
namespace: string
|
|
14
|
+
event: string
|
|
15
|
+
target: string
|
|
16
|
+
holdingId?: string
|
|
17
|
+
companyId?: string
|
|
18
|
+
employeeId?: string
|
|
19
|
+
individualId?: string
|
|
20
|
+
roleId?: string
|
|
21
|
+
userIp?: string
|
|
22
|
+
specialRole?: string
|
|
23
|
+
email?: string
|
|
8
24
|
}
|
|
9
25
|
|
|
10
26
|
export interface IAuditLogTransport {
|