@payfit/audit-log 1.0.0-alpha2 → 1.0.0-alpha4

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.
@@ -0,0 +1,18 @@
1
+ export interface AuditLogData {
2
+ countryCode: string;
3
+ payload?: object;
4
+ isImpersonated?: boolean;
5
+ isSystem?: boolean;
6
+ namespace: string;
7
+ service: string;
8
+ event: string;
9
+ holdingId?: string;
10
+ companyId?: string;
11
+ employeeId?: string;
12
+ individualId?: string;
13
+ roleId?: string;
14
+ userIp?: string;
15
+ specialRole?: string;
16
+ email?: string;
17
+ }
18
+ export declare function auditLog(params: AuditLogData): Promise<void>;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAAmC;AACnC,sEAAuD;AAqBvD,SAAsB,QAAQ,CAAC,MAAoB;;QACjD,MAAM,IAAI,GAAG,SAAM,EAAE,CAAA;QACrB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;QAC3C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QAEtC,MAAM,GAAG,qBACJ,MAAM,IACT,EAAE,EAAE,IAAI,EACR,WAAW;YACX,SAAS,GACV,CAAA;QAED,MAAM,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;CAAA;AAbD,4BAaC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAAmC;AACnC,sEAAuD;AAoBvD,SAAsB,QAAQ,CAAC,MAAoB;;QACjD,MAAM,IAAI,GAAG,SAAM,EAAE,CAAA;QACrB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;QAC3C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QAEtC,MAAM,GAAG,qBACJ,MAAM,IACT,EAAE,EAAE,IAAI,EACR,WAAW;YACX,SAAS,GACV,CAAA;QAED,MAAM,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;CAAA;AAbD,4BAaC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Audit Logs
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: damian.bursztyn@payfit.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { AxiosPromise, AxiosInstance } from 'axios';
13
+ import { Configuration } from '../configuration';
14
+ import { RequestArgs, BaseAPI } from '../base';
15
+ import { InlineObject } from '../model';
16
+ /**
17
+ * DefaultApi - axios parameter creator
18
+ * @export
19
+ */
20
+ export declare const DefaultApiAxiosParamCreator: (configuration?: Configuration | undefined) => {
21
+ /**
22
+ *
23
+ * @summary Creates Audit Log event
24
+ * @param {InlineObject} inlineObject
25
+ * @param {*} [options] Override http request option.
26
+ * @throws {RequiredError}
27
+ */
28
+ v1LogPost(inlineObject: InlineObject, options?: any): RequestArgs;
29
+ };
30
+ /**
31
+ * DefaultApi - functional programming interface
32
+ * @export
33
+ */
34
+ export declare const DefaultApiFp: (configuration?: Configuration | undefined) => {
35
+ /**
36
+ *
37
+ * @summary Creates Audit Log event
38
+ * @param {InlineObject} inlineObject
39
+ * @param {*} [options] Override http request option.
40
+ * @throws {RequiredError}
41
+ */
42
+ v1LogPost(inlineObject: InlineObject, options?: any): (axios?: AxiosInstance | undefined, basePath?: string | undefined) => AxiosPromise<void>;
43
+ };
44
+ /**
45
+ * DefaultApi - factory interface
46
+ * @export
47
+ */
48
+ export declare const DefaultApiFactory: (configuration?: Configuration | undefined, basePath?: string | undefined, axios?: AxiosInstance | undefined) => {
49
+ /**
50
+ *
51
+ * @summary Creates Audit Log event
52
+ * @param {InlineObject} inlineObject
53
+ * @param {*} [options] Override http request option.
54
+ * @throws {RequiredError}
55
+ */
56
+ v1LogPost(inlineObject: InlineObject, options?: any): AxiosPromise<void>;
57
+ };
58
+ /**
59
+ * DefaultApi - object-oriented interface
60
+ * @export
61
+ * @class DefaultApi
62
+ * @extends {BaseAPI}
63
+ */
64
+ export declare class DefaultApi extends BaseAPI {
65
+ /**
66
+ *
67
+ * @summary Creates Audit Log event
68
+ * @param {InlineObject} inlineObject
69
+ * @param {*} [options] Override http request option.
70
+ * @throws {RequiredError}
71
+ * @memberof DefaultApi
72
+ */
73
+ v1LogPost(inlineObject: InlineObject, options?: any): AxiosPromise<void>;
74
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Audit Logs
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: damian.bursztyn@payfit.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ export * from './api/default-api';
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Audit Logs
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: damian.bursztyn@payfit.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { Configuration } from "./configuration";
13
+ import { AxiosInstance } from 'axios';
14
+ export declare const BASE_PATH: string;
15
+ /**
16
+ *
17
+ * @export
18
+ */
19
+ export declare const COLLECTION_FORMATS: {
20
+ csv: string;
21
+ ssv: string;
22
+ tsv: string;
23
+ pipes: string;
24
+ };
25
+ /**
26
+ *
27
+ * @export
28
+ * @interface RequestArgs
29
+ */
30
+ export interface RequestArgs {
31
+ url: string;
32
+ options: any;
33
+ }
34
+ /**
35
+ *
36
+ * @export
37
+ * @class BaseAPI
38
+ */
39
+ export declare class BaseAPI {
40
+ protected basePath: string;
41
+ protected axios: AxiosInstance;
42
+ protected configuration: Configuration | undefined;
43
+ constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
44
+ }
45
+ /**
46
+ *
47
+ * @export
48
+ * @class RequiredError
49
+ * @extends {Error}
50
+ */
51
+ export declare class RequiredError extends Error {
52
+ field: string;
53
+ name: "RequiredError";
54
+ constructor(field: string, msg?: string);
55
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Audit Logs
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: damian.bursztyn@payfit.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ export interface ConfigurationParameters {
13
+ apiKey?: string | ((name: string) => string);
14
+ username?: string;
15
+ password?: string;
16
+ accessToken?: string | ((name?: string, scopes?: string[]) => string);
17
+ basePath?: string;
18
+ baseOptions?: any;
19
+ }
20
+ export declare class Configuration {
21
+ /**
22
+ * parameter for apiKey security
23
+ * @param name security name
24
+ * @memberof Configuration
25
+ */
26
+ apiKey?: string | ((name: string) => string);
27
+ /**
28
+ * parameter for basic security
29
+ *
30
+ * @type {string}
31
+ * @memberof Configuration
32
+ */
33
+ username?: string;
34
+ /**
35
+ * parameter for basic security
36
+ *
37
+ * @type {string}
38
+ * @memberof Configuration
39
+ */
40
+ password?: string;
41
+ /**
42
+ * parameter for oauth2 security
43
+ * @param name security name
44
+ * @param scopes oauth2 scope
45
+ * @memberof Configuration
46
+ */
47
+ accessToken?: string | ((name?: string, scopes?: string[]) => string);
48
+ /**
49
+ * override base path
50
+ *
51
+ * @type {string}
52
+ * @memberof Configuration
53
+ */
54
+ basePath?: string;
55
+ /**
56
+ * base options for axios calls
57
+ *
58
+ * @type {any}
59
+ * @memberof Configuration
60
+ */
61
+ baseOptions?: any;
62
+ constructor(param?: ConfigurationParameters);
63
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Audit Logs
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: damian.bursztyn@payfit.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ export * from "./api";
13
+ export * from "./configuration";
@@ -0,0 +1 @@
1
+ export * from './inline-object';
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Audit Logs
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: damian.bursztyn@payfit.com
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ /**
13
+ *
14
+ * @export
15
+ * @interface InlineObject
16
+ */
17
+ export interface InlineObject {
18
+ /**
19
+ * Audit log event unique identifier
20
+ * @type {string}
21
+ * @memberof InlineObject
22
+ */
23
+ id: string;
24
+ /**
25
+ * Audit log event country code
26
+ * @type {string}
27
+ * @memberof InlineObject
28
+ */
29
+ countryCode: CountryCodeEnum;
30
+ /**
31
+ * Audit log event payload
32
+ * @type {object}
33
+ * @memberof InlineObject
34
+ */
35
+ payload?: object;
36
+ /**
37
+ *
38
+ * @type {boolean}
39
+ * @memberof InlineObject
40
+ */
41
+ isImpersonated?: boolean;
42
+ /**
43
+ *
44
+ * @type {boolean}
45
+ * @memberof InlineObject
46
+ */
47
+ isSystem?: boolean;
48
+ /**
49
+ * Audit log event namespace (business related)
50
+ * @type {string}
51
+ * @memberof InlineObject
52
+ */
53
+ namespace: string;
54
+ /**
55
+ * Audit log event namespace (technical related)
56
+ * @type {string}
57
+ * @memberof InlineObject
58
+ */
59
+ service: string;
60
+ /**
61
+ * Audit log event type
62
+ * @type {string}
63
+ * @memberof InlineObject
64
+ */
65
+ event?: string;
66
+ /**
67
+ * Audit log event environment
68
+ * @type {string}
69
+ * @memberof InlineObject
70
+ */
71
+ environment?: string;
72
+ /**
73
+ * Audit log event holdingId
74
+ * @type {string}
75
+ * @memberof InlineObject
76
+ */
77
+ holdingId?: string;
78
+ /**
79
+ * Audit log event companyId
80
+ * @type {string}
81
+ * @memberof InlineObject
82
+ */
83
+ companyId?: string;
84
+ /**
85
+ * Audit log event employeeId
86
+ * @type {string}
87
+ * @memberof InlineObject
88
+ */
89
+ employeeId?: string;
90
+ /**
91
+ * Audit log event individualId
92
+ * @type {string}
93
+ * @memberof InlineObject
94
+ */
95
+ individualId?: string;
96
+ /**
97
+ * Audit log event roleId
98
+ * @type {string}
99
+ * @memberof InlineObject
100
+ */
101
+ roleId?: string;
102
+ /**
103
+ * Audit log event userIp
104
+ * @type {string}
105
+ * @memberof InlineObject
106
+ */
107
+ userIp?: string;
108
+ /**
109
+ * Audit log event specialRole
110
+ * @type {string}
111
+ * @memberof InlineObject
112
+ */
113
+ specialRole?: string;
114
+ /**
115
+ * Audit log event email
116
+ * @type {string}
117
+ * @memberof InlineObject
118
+ */
119
+ email?: string;
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
+ }
@@ -24,34 +24,4 @@ var CountryCodeEnum;
24
24
  CountryCodeEnum["ES"] = "es";
25
25
  CountryCodeEnum["GB"] = "gb";
26
26
  })(CountryCodeEnum = exports.CountryCodeEnum || (exports.CountryCodeEnum = {}));
27
- /**
28
- * @export
29
- * @enum {string}
30
- */
31
- var NamespaceEnum;
32
- (function (NamespaceEnum) {
33
- NamespaceEnum["MANAGER"] = "manager";
34
- NamespaceEnum["VERSIONER"] = "versioner";
35
- NamespaceEnum["MAILER"] = "mailer";
36
- })(NamespaceEnum = exports.NamespaceEnum || (exports.NamespaceEnum = {}));
37
- /**
38
- * @export
39
- * @enum {string}
40
- */
41
- var ServiceEnum;
42
- (function (ServiceEnum) {
43
- ServiceEnum["FILES_V2"] = "files-v2";
44
- ServiceEnum["PAYROLL_V2"] = "payroll-v2";
45
- ServiceEnum["HR_API"] = "hr-api";
46
- })(ServiceEnum = exports.ServiceEnum || (exports.ServiceEnum = {}));
47
- /**
48
- * @export
49
- * @enum {string}
50
- */
51
- var EventEnum;
52
- (function (EventEnum) {
53
- EventEnum["CREATE"] = "create";
54
- EventEnum["UPDATE"] = "update";
55
- EventEnum["DELETE"] = "delete";
56
- })(EventEnum = exports.EventEnum || (exports.EventEnum = {}));
57
27
  //# 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;;AAkHH;;;MAGM;AACN,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,4BAAS,CAAA;AACb,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B;AACD;;;MAGM;AACN,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,kCAAiB,CAAA;AACrB,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB;AACD;;;MAGM;AACN,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,gCAAiB,CAAA;AACrB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AACD;;;MAGM;AACN,IAAY,SAIX;AAJD,WAAY,SAAS;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACrB,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB"}
1
+ {"version":3,"file":"inline-object.js","sourceRoot":"","sources":["../../../../src/transport/generated/model/inline-object.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG;;AAkHH;;;MAGM;AACN,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,4BAAS,CAAA;AACb,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B"}
@@ -0,0 +1,2 @@
1
+ import { AuditLogCreationData } from './interface';
2
+ export declare function auditLog(auditLogData: AuditLogCreationData): Promise<import("axios").AxiosResponse<void>>;
@@ -20,33 +20,13 @@ 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
- const model_1 = require("./generated/model");
24
23
  const api = new generated_1.DefaultApi({
25
- basePath: 'http://localhost:8090',
24
+ basePath: process.env.AUDIT_LOG_API_URL,
26
25
  });
27
- const stringToCountry = {
28
- FR: model_1.CountryCodeEnum.FR,
29
- DE: model_1.CountryCodeEnum.DE,
30
- GB: model_1.CountryCodeEnum.GB,
31
- ES: model_1.CountryCodeEnum.ES,
32
- IT: model_1.CountryCodeEnum.IT,
33
- };
34
- function serializeCountry(country) {
35
- return stringToCountry[country];
36
- }
37
- function serializeNamespace(namespace) {
38
- return namespace;
39
- }
40
- function serializeService(service) {
41
- return service;
42
- }
43
- function serializeEvent(event) {
44
- return event;
45
- }
46
26
  function auditLog(auditLogData) {
47
27
  return __awaiter(this, void 0, void 0, function* () {
48
- const { countryCode, namespace, service, event, payload } = auditLogData, data = __rest(auditLogData, ["countryCode", "namespace", "service", "event", "payload"]);
49
- const dataToSend = Object.assign({}, data, { countryCode: serializeCountry(countryCode), namespace: serializeNamespace(namespace), service: serializeService(service), event: serializeEvent(event), payload });
28
+ const { countryCode, payload } = auditLogData, data = __rest(auditLogData, ["countryCode", "payload"]);
29
+ const dataToSend = Object.assign({}, data, { countryCode: countryCode, payload });
50
30
  return api.v1LogPost(dataToSend);
51
31
  });
52
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../src/transport/implementation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,2CAAwC;AACxC,6CAK0B;AAI1B,MAAM,GAAG,GAAG,IAAI,sBAAU,CAAC;IACzB,QAAQ,EAAE,uBAAuB;CAClC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG;IACtB,EAAE,EAAE,uBAAe,CAAC,EAAE;IACtB,EAAE,EAAE,uBAAe,CAAC,EAAE;IACtB,EAAE,EAAE,uBAAe,CAAC,EAAE;IACtB,EAAE,EAAE,uBAAe,CAAC,EAAE;IACtB,EAAE,EAAE,uBAAe,CAAC,EAAE;CACvB,CAAA;AACD,SAAS,gBAAgB,CACvB,OAAqC;IAErC,OAAO,eAAe,CAAC,OAAO,CAAC,CAAA;AACjC,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,OAAO,SAAgB,CAAA;AACzB,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAoB;IAC5C,OAAO,OAAc,CAAA;AACvB,CAAC;AAED,SAAS,cAAc,CAAC,KAAY;IAClC,OAAO,KAAY,CAAA;AACrB,CAAC;AAED,SAAsB,QAAQ,CAAC,YAAkC;;QAC/D,MAAM,EACJ,WAAW,EACX,SAAS,EACT,OAAO,EACP,KAAK,EACL,OAAO,KAEL,YAAY,EADd,wFACc,CAAA;QAEhB,MAAM,UAAU,qBACX,IAAI,IACP,WAAW,EAAE,gBAAgB,CAAC,WAAW,CAAC,EAC1C,SAAS,EAAE,kBAAkB,CAAC,SAAS,CAAC,EACxC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAClC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAC5B,OAAO,GACR,CAAA;QAED,OAAO,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC;CAAA;AApBD,4BAoBC"}
1
+ {"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../src/transport/implementation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AAIxC,MAAM,GAAG,GAAG,IAAI,sBAAU,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;CACxC,CAAC,CAAA;AAEF,SAAsB,QAAQ,CAAC,YAAkC;;QAC/D,MAAM,EAAE,WAAW,EAAE,OAAO,KAAc,YAAY,EAAxB,uDAAwB,CAAA;QAEtD,MAAM,UAAU,qBACX,IAAI,IACP,WAAW,EAAE,WAA8B,EAC3C,OAAO,GACR,CAAA;QAED,OAAO,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC;CAAA;AAVD,4BAUC"}
@@ -0,0 +1,5 @@
1
+ import { AuditLogData } from '..';
2
+ export declare type AuditLogCreationData = AuditLogData & {
3
+ id: string;
4
+ timestamp: number;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payfit/audit-log",
3
- "version": "1.0.0-alpha2",
3
+ "version": "1.0.0-alpha4",
4
4
  "description": "Library to handle audit logs at Payfit",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -8,17 +8,16 @@
8
8
  "build": "rimraf dist && tsc",
9
9
  "prepublish": "npm run build"
10
10
  },
11
- "types": "./src/index.ts",
12
11
  "author": "",
13
12
  "license": "ISC",
14
13
  "dependencies": {
15
- "axios": "^0.19.2",
16
- "lodash": "^4.17.15",
17
- "uuid": "^7.0.0"
14
+ "axios": "0.19.2",
15
+ "lodash": "4.17.15",
16
+ "uuid": "7.0.0"
18
17
  },
19
18
  "devDependencies": {
20
- "@types/lodash": "^4.14.149",
21
- "@types/uuid": "^3.4.7",
19
+ "@types/lodash": "4.14.149",
20
+ "@types/uuid": "3.4.7",
22
21
  "prettier": "1.18.2",
23
22
  "rimraf": "2.6.3",
24
23
  "ts-node": "8.3.0",
package/src/index.ts CHANGED
@@ -1,15 +1,14 @@
1
1
  import { v4 as uuidV4 } from 'uuid'
2
2
  import * as transport from './transport/implementation'
3
- import { Country, Event, ServiceName } from './types'
4
3
 
5
4
  export interface AuditLogData {
6
- countryCode: Country
5
+ countryCode: string
7
6
  payload?: object
8
7
  isImpersonated?: boolean
9
8
  isSystem?: boolean
10
9
  namespace: string
11
- service: ServiceName
12
- event: Event
10
+ service: string
11
+ event: string
13
12
  holdingId?: string
14
13
  companyId?: string
15
14
  employeeId?: string
@@ -54,19 +54,19 @@ export interface InlineObject {
54
54
  * @type {string}
55
55
  * @memberof InlineObject
56
56
  */
57
- namespace: NamespaceEnum;
57
+ namespace: string;
58
58
  /**
59
59
  * Audit log event namespace (technical related)
60
60
  * @type {string}
61
61
  * @memberof InlineObject
62
62
  */
63
- service: ServiceEnum;
63
+ service: string;
64
64
  /**
65
65
  * Audit log event type
66
66
  * @type {string}
67
67
  * @memberof InlineObject
68
68
  */
69
- event?: EventEnum;
69
+ event?: string;
70
70
  /**
71
71
  * Audit log event environment
72
72
  * @type {string}
@@ -134,33 +134,6 @@ export enum CountryCodeEnum {
134
134
  ES = 'es',
135
135
  GB = 'gb'
136
136
  }
137
- /**
138
- * @export
139
- * @enum {string}
140
- */
141
- export enum NamespaceEnum {
142
- MANAGER = 'manager',
143
- VERSIONER = 'versioner',
144
- MAILER = 'mailer'
145
- }
146
- /**
147
- * @export
148
- * @enum {string}
149
- */
150
- export enum ServiceEnum {
151
- FILES_V2 = 'files-v2',
152
- PAYROLL_V2 = 'payroll-v2',
153
- HR_API = 'hr-api'
154
- }
155
- /**
156
- * @export
157
- * @enum {string}
158
- */
159
- export enum EventEnum {
160
- CREATE = 'create',
161
- UPDATE = 'update',
162
- DELETE = 'delete'
163
- }
164
137
 
165
138
 
166
139
 
@@ -1,61 +1,17 @@
1
- import { v4 as uuidV4 } from 'uuid'
2
- import { invert } from 'lodash'
3
-
4
1
  import { DefaultApi } from './generated'
5
- import {
6
- CountryCodeEnum,
7
- NamespaceEnum,
8
- EventEnum,
9
- ServiceEnum,
10
- } from './generated/model'
2
+ import { CountryCodeEnum } from './generated/model'
11
3
  import { AuditLogCreationData } from './interface'
12
- import { ServiceName, Event } from '../types'
13
4
 
14
5
  const api = new DefaultApi({
15
- basePath: 'http://localhost:8090',
6
+ basePath: process.env.AUDIT_LOG_API_URL,
16
7
  })
17
8
 
18
- const stringToCountry = {
19
- FR: CountryCodeEnum.FR,
20
- DE: CountryCodeEnum.DE,
21
- GB: CountryCodeEnum.GB,
22
- ES: CountryCodeEnum.ES,
23
- IT: CountryCodeEnum.IT,
24
- }
25
- function serializeCountry(
26
- country: keyof typeof stringToCountry
27
- ): CountryCodeEnum {
28
- return stringToCountry[country]
29
- }
30
-
31
- function serializeNamespace(namespace: string): NamespaceEnum {
32
- return namespace as any
33
- }
34
-
35
- function serializeService(service: ServiceName): ServiceEnum {
36
- return service as any
37
- }
38
-
39
- function serializeEvent(event: Event): EventEnum {
40
- return event as any
41
- }
42
-
43
9
  export async function auditLog(auditLogData: AuditLogCreationData) {
44
- const {
45
- countryCode,
46
- namespace,
47
- service,
48
- event,
49
- payload,
50
- ...data
51
- } = auditLogData
10
+ const { countryCode, payload, ...data } = auditLogData
52
11
 
53
12
  const dataToSend = {
54
13
  ...data,
55
- countryCode: serializeCountry(countryCode),
56
- namespace: serializeNamespace(namespace),
57
- service: serializeService(service),
58
- event: serializeEvent(event),
14
+ countryCode: countryCode as CountryCodeEnum,
59
15
  payload,
60
16
  }
61
17
 
package/tsconfig.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "declaration": true,
3
4
  "target": "es6",
4
5
  "module": "commonjs",
5
6
  "lib": ["es7", "esnext.asynciterable", "es2017"],
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/src/types.ts DELETED
@@ -1,11 +0,0 @@
1
- export type Country = 'FR' | 'ES' | 'DE' | 'GB' | 'IT'
2
-
3
- export type ServiceName =
4
- | 'auth'
5
- | 'files'
6
- | 'permissions'
7
- | 'payroll-api'
8
- | 'hr-api'
9
- | 'back-office'
10
-
11
- export type Event = 'create' | 'update' | 'delete' | 'login' | 'logout'