@payfit/audit-log 1.0.0-alpha

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.
Files changed (41) hide show
  1. package/.prettierrc +5 -0
  2. package/dist/index.js +40 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/transport/generated/api/default-api.js +131 -0
  5. package/dist/transport/generated/api/default-api.js.map +1 -0
  6. package/dist/transport/generated/api.js +19 -0
  7. package/dist/transport/generated/api.js.map +1 -0
  8. package/dist/transport/generated/base.js +63 -0
  9. package/dist/transport/generated/base.js.map +1 -0
  10. package/dist/transport/generated/configuration.js +26 -0
  11. package/dist/transport/generated/configuration.js.map +1 -0
  12. package/dist/transport/generated/index.js +20 -0
  13. package/dist/transport/generated/index.js.map +1 -0
  14. package/dist/transport/generated/model/index.js +7 -0
  15. package/dist/transport/generated/model/index.js.map +1 -0
  16. package/dist/transport/generated/model/inline-object.js +57 -0
  17. package/dist/transport/generated/model/inline-object.js.map +1 -0
  18. package/dist/transport/implementation.js +54 -0
  19. package/dist/transport/implementation.js.map +1 -0
  20. package/dist/transport/interface.js +3 -0
  21. package/dist/transport/interface.js.map +1 -0
  22. package/dist/types.js +3 -0
  23. package/dist/types.js.map +1 -0
  24. package/openapi-codegen-config.yml +6 -0
  25. package/package.json +29 -0
  26. package/src/index.ts +46 -0
  27. package/src/transport/generated/.openapi-generator/VERSION +1 -0
  28. package/src/transport/generated/.openapi-generator-ignore +23 -0
  29. package/src/transport/generated/api/default-api.ts +131 -0
  30. package/src/transport/generated/api.ts +17 -0
  31. package/src/transport/generated/base.ts +70 -0
  32. package/src/transport/generated/configuration.ts +75 -0
  33. package/src/transport/generated/git_push.sh +58 -0
  34. package/src/transport/generated/index.ts +16 -0
  35. package/src/transport/generated/model/index.ts +1 -0
  36. package/src/transport/generated/model/inline-object.ts +166 -0
  37. package/src/transport/implementation.ts +63 -0
  38. package/src/transport/interface.ts +6 -0
  39. package/src/types.ts +11 -0
  40. package/tsconfig.json +24 -0
  41. package/tslint.json +12 -0
package/.prettierrc ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "semi": false,
3
+ "singleQuote": true,
4
+ "trailingComma": "es5"
5
+ }
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
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 __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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const uuid_1 = require("uuid");
19
+ const transport = __importStar(require("./transport/implementation"));
20
+ function auditLog(params) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const uuid = uuid_1.v4();
23
+ const environment = process.env.ENVIRONMENT;
24
+ const timestamp = new Date().getTime();
25
+ const log = Object.assign({}, params, { id: uuid, environment,
26
+ timestamp });
27
+ yield transport.auditLog(log);
28
+ });
29
+ }
30
+ exports.auditLog = auditLog;
31
+ auditLog({
32
+ countryCode: 'FR',
33
+ namespace: 'mailer',
34
+ event: 'create',
35
+ service: 'hr-api',
36
+ payload: {
37
+ test: true,
38
+ },
39
+ }).catch(e => console.log('ERR:', e));
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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;AAED,QAAQ,CAAC;IACP,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,QAAQ;IACnB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE;QACP,IAAI,EAAE,IAAI;KACX;CACF,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,131 @@
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
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
18
+ result["default"] = mod;
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const globalImportUrl = __importStar(require("url"));
26
+ const axios_1 = __importDefault(require("axios"));
27
+ // Some imports not used depending on template conditions
28
+ // @ts-ignore
29
+ const base_1 = require("../base");
30
+ /**
31
+ * DefaultApi - axios parameter creator
32
+ * @export
33
+ */
34
+ exports.DefaultApiAxiosParamCreator = function (configuration) {
35
+ return {
36
+ /**
37
+ *
38
+ * @summary Creates Audit Log event
39
+ * @param {InlineObject} inlineObject
40
+ * @param {*} [options] Override http request option.
41
+ * @throws {RequiredError}
42
+ */
43
+ v1LogPost(inlineObject, options = {}) {
44
+ // verify required parameter 'inlineObject' is not null or undefined
45
+ if (inlineObject === null || inlineObject === undefined) {
46
+ throw new base_1.RequiredError('inlineObject', 'Required parameter inlineObject was null or undefined when calling v1LogPost.');
47
+ }
48
+ const localVarPath = `/v1/log`;
49
+ const localVarUrlObj = globalImportUrl.parse(localVarPath, true);
50
+ let baseOptions;
51
+ if (configuration) {
52
+ baseOptions = configuration.baseOptions;
53
+ }
54
+ const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
55
+ const localVarHeaderParameter = {};
56
+ const localVarQueryParameter = {};
57
+ localVarHeaderParameter['Content-Type'] = 'application/json';
58
+ localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
59
+ // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
60
+ delete localVarUrlObj.search;
61
+ localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
62
+ const needsSerialization = (typeof inlineObject !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
63
+ localVarRequestOptions.data = needsSerialization ? JSON.stringify(inlineObject !== undefined ? inlineObject : {}) : (inlineObject || "");
64
+ return {
65
+ url: globalImportUrl.format(localVarUrlObj),
66
+ options: localVarRequestOptions,
67
+ };
68
+ },
69
+ };
70
+ };
71
+ /**
72
+ * DefaultApi - functional programming interface
73
+ * @export
74
+ */
75
+ exports.DefaultApiFp = function (configuration) {
76
+ return {
77
+ /**
78
+ *
79
+ * @summary Creates Audit Log event
80
+ * @param {InlineObject} inlineObject
81
+ * @param {*} [options] Override http request option.
82
+ * @throws {RequiredError}
83
+ */
84
+ v1LogPost(inlineObject, options) {
85
+ const localVarAxiosArgs = exports.DefaultApiAxiosParamCreator(configuration).v1LogPost(inlineObject, options);
86
+ return (axios = axios_1.default, basePath = base_1.BASE_PATH) => {
87
+ const axiosRequestArgs = Object.assign({}, localVarAxiosArgs.options, { url: basePath + localVarAxiosArgs.url });
88
+ return axios.request(axiosRequestArgs);
89
+ };
90
+ },
91
+ };
92
+ };
93
+ /**
94
+ * DefaultApi - factory interface
95
+ * @export
96
+ */
97
+ exports.DefaultApiFactory = function (configuration, basePath, axios) {
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, options) {
107
+ return exports.DefaultApiFp(configuration).v1LogPost(inlineObject, options)(axios, basePath);
108
+ },
109
+ };
110
+ };
111
+ /**
112
+ * DefaultApi - object-oriented interface
113
+ * @export
114
+ * @class DefaultApi
115
+ * @extends {BaseAPI}
116
+ */
117
+ class DefaultApi extends base_1.BaseAPI {
118
+ /**
119
+ *
120
+ * @summary Creates Audit Log event
121
+ * @param {InlineObject} inlineObject
122
+ * @param {*} [options] Override http request option.
123
+ * @throws {RequiredError}
124
+ * @memberof DefaultApi
125
+ */
126
+ v1LogPost(inlineObject, options) {
127
+ return exports.DefaultApiFp(this.configuration).v1LogPost(inlineObject, options)(this.axios, this.basePath);
128
+ }
129
+ }
130
+ exports.DefaultApi = DefaultApi;
131
+ //# sourceMappingURL=default-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-api.js","sourceRoot":"","sources":["../../../../src/transport/generated/api/default-api.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,19 @@
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
+ function __export(m) {
15
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
16
+ }
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __export(require("./api/default-api"));
19
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/transport/generated/api.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG;;;;;AAIH,uCAAkC"}
@@ -0,0 +1,63 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ // Some imports not used depending on template conditions
19
+ // @ts-ignore
20
+ const axios_1 = __importDefault(require("axios"));
21
+ exports.BASE_PATH = "http://localhost:8081/v1".replace(/\/+$/, "");
22
+ /**
23
+ *
24
+ * @export
25
+ */
26
+ exports.COLLECTION_FORMATS = {
27
+ csv: ",",
28
+ ssv: " ",
29
+ tsv: "\t",
30
+ pipes: "|",
31
+ };
32
+ /**
33
+ *
34
+ * @export
35
+ * @class BaseAPI
36
+ */
37
+ class BaseAPI {
38
+ constructor(configuration, basePath = exports.BASE_PATH, axios = axios_1.default) {
39
+ this.basePath = basePath;
40
+ this.axios = axios;
41
+ if (configuration) {
42
+ this.configuration = configuration;
43
+ this.basePath = configuration.basePath || this.basePath;
44
+ }
45
+ }
46
+ }
47
+ exports.BaseAPI = BaseAPI;
48
+ ;
49
+ /**
50
+ *
51
+ * @export
52
+ * @class RequiredError
53
+ * @extends {Error}
54
+ */
55
+ class RequiredError extends Error {
56
+ constructor(field, msg) {
57
+ super(msg);
58
+ this.field = field;
59
+ this.name = "RequiredError";
60
+ }
61
+ }
62
+ exports.RequiredError = RequiredError;
63
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/transport/generated/base.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG;;;;;AAIH,yDAAyD;AACzD,aAAa;AACb,kDAAiE;AAEpD,QAAA,SAAS,GAAG,0BAA0B,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAExE;;;GAGG;AACU,QAAA,kBAAkB,GAAG;IAC9B,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,GAAG;CACb,CAAC;AAYF;;;;GAIG;AACH,MAAa,OAAO;IAGhB,YAAY,aAA6B,EAAY,WAAmB,iBAAS,EAAY,QAAuB,eAAW;QAA1E,aAAQ,GAAR,QAAQ,CAAoB;QAAY,UAAK,GAAL,KAAK,CAA6B;QAC3H,IAAI,aAAa,EAAE;YACf,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;YACnC,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;SAC3D;IACL,CAAC;CACJ;AATD,0BASC;AAAA,CAAC;AAEF;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,KAAK;IAEpC,YAAmB,KAAa,EAAE,GAAY;QAC1C,KAAK,CAAC,GAAG,CAAC,CAAC;QADI,UAAK,GAAL,KAAK,CAAQ;QADhC,SAAI,GAAoB,eAAe,CAAC;IAGxC,CAAC;CACJ;AALD,sCAKC"}
@@ -0,0 +1,26 @@
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
+ class Configuration {
16
+ constructor(param = {}) {
17
+ this.apiKey = param.apiKey;
18
+ this.username = param.username;
19
+ this.password = param.password;
20
+ this.accessToken = param.accessToken;
21
+ this.basePath = param.basePath;
22
+ this.baseOptions = param.baseOptions;
23
+ }
24
+ }
25
+ exports.Configuration = Configuration;
26
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/transport/generated/configuration.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG;;AAYH,MAAa,aAAa;IA2CtB,YAAY,QAAiC,EAAE;QAC3C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACzC,CAAC;CACJ;AAnDD,sCAmDC"}
@@ -0,0 +1,20 @@
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
+ function __export(m) {
15
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
16
+ }
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __export(require("./api"));
19
+ __export(require("./configuration"));
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/generated/index.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB;;;;;;;;;;GAUG;;;;;AAGH,2BAAsB;AACtB,qCAAgC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ function __export(m) {
3
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
+ }
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ __export(require("./inline-object"));
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transport/generated/model/index.ts"],"names":[],"mappings":";;;;;AAAA,qCAAgC"}
@@ -0,0 +1,57 @@
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
+ /**
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
+ /**
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
+ //# 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;;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"}
@@ -0,0 +1,54 @@
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
+ const model_1 = require("./generated/model");
24
+ const api = new generated_1.DefaultApi({
25
+ basePath: 'http://localhost:8090',
26
+ });
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
+ function auditLog(auditLogData) {
47
+ 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 });
50
+ return api.v1LogPost(dataToSend);
51
+ });
52
+ }
53
+ exports.auditLog = auditLog;
54
+ //# sourceMappingURL=implementation.js.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/transport/interface.ts"],"names":[],"mappings":""}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ withSeparateModelsAndApi: true
2
+ apiPackage: 'api'
3
+ modelPackage: 'model'
4
+ enumPropertyNaming: UPPERCASE
5
+ modelPropertyNaming: camelCase
6
+ withoutPrefixEnums: true
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@payfit/audit-log",
3
+ "version": "1.0.0-alpha",
4
+ "description": "Library to handle audit logs at Payfit",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "rimraf dist && tsc",
9
+ "prepublish": "npm run build"
10
+ },
11
+ "author": "",
12
+ "license": "ISC",
13
+ "dependencies": {
14
+ "axios": "^0.19.2",
15
+ "lodash": "^4.17.15",
16
+ "uuid": "^7.0.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/lodash": "^4.14.149",
20
+ "@types/uuid": "^3.4.7",
21
+ "prettier": "1.18.2",
22
+ "rimraf": "2.6.3",
23
+ "ts-node": "8.3.0",
24
+ "ts-node-dev": "1.0.0-pre.40",
25
+ "tslint": "5.18.0",
26
+ "tslint-config-prettier": "1.18.0",
27
+ "typescript": "3.5.3"
28
+ }
29
+ }
package/src/index.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { v4 as uuidV4 } from 'uuid'
2
+ import * as transport from './transport/implementation'
3
+ import { Country, Event, ServiceName } from './types'
4
+
5
+ export interface AuditLogData {
6
+ countryCode: Country
7
+ payload?: object
8
+ isImpersonated?: boolean
9
+ isSystem?: boolean
10
+ namespace: string
11
+ service: ServiceName
12
+ event: Event
13
+ holdingId?: string
14
+ companyId?: string
15
+ employeeId?: string
16
+ individualId?: string
17
+ roleId?: string
18
+ userIp?: string
19
+ specialRole?: string
20
+ email?: string
21
+ }
22
+
23
+ export async function auditLog(params: AuditLogData): Promise<void> {
24
+ const uuid = uuidV4()
25
+ const environment = process.env.ENVIRONMENT
26
+ const timestamp = new Date().getTime()
27
+
28
+ const log = {
29
+ ...params,
30
+ id: uuid,
31
+ environment,
32
+ timestamp,
33
+ }
34
+
35
+ await transport.auditLog(log)
36
+ }
37
+
38
+ auditLog({
39
+ countryCode: 'FR',
40
+ namespace: 'mailer',
41
+ event: 'create',
42
+ service: 'hr-api',
43
+ payload: {
44
+ test: true,
45
+ },
46
+ }).catch(e => console.log('ERR:', e))
@@ -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
+
@@ -0,0 +1,70 @@
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 { Configuration } from "./configuration";
16
+ // Some imports not used depending on template conditions
17
+ // @ts-ignore
18
+ import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
19
+
20
+ export const BASE_PATH = "http://localhost:8081/v1".replace(/\/+$/, "");
21
+
22
+ /**
23
+ *
24
+ * @export
25
+ */
26
+ export const COLLECTION_FORMATS = {
27
+ csv: ",",
28
+ ssv: " ",
29
+ tsv: "\t",
30
+ pipes: "|",
31
+ };
32
+
33
+ /**
34
+ *
35
+ * @export
36
+ * @interface RequestArgs
37
+ */
38
+ export interface RequestArgs {
39
+ url: string;
40
+ options: any;
41
+ }
42
+
43
+ /**
44
+ *
45
+ * @export
46
+ * @class BaseAPI
47
+ */
48
+ export class BaseAPI {
49
+ protected configuration: Configuration | undefined;
50
+
51
+ constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
52
+ if (configuration) {
53
+ this.configuration = configuration;
54
+ this.basePath = configuration.basePath || this.basePath;
55
+ }
56
+ }
57
+ };
58
+
59
+ /**
60
+ *
61
+ * @export
62
+ * @class RequiredError
63
+ * @extends {Error}
64
+ */
65
+ export class RequiredError extends Error {
66
+ name: "RequiredError" = "RequiredError";
67
+ constructor(public field: string, msg?: string) {
68
+ super(msg);
69
+ }
70
+ }
@@ -0,0 +1,75 @@
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
+ export interface ConfigurationParameters {
16
+ apiKey?: string | ((name: string) => string);
17
+ username?: string;
18
+ password?: string;
19
+ accessToken?: string | ((name?: string, scopes?: string[]) => string);
20
+ basePath?: string;
21
+ baseOptions?: any;
22
+ }
23
+
24
+ export class Configuration {
25
+ /**
26
+ * parameter for apiKey security
27
+ * @param name security name
28
+ * @memberof Configuration
29
+ */
30
+ apiKey?: string | ((name: string) => string);
31
+ /**
32
+ * parameter for basic security
33
+ *
34
+ * @type {string}
35
+ * @memberof Configuration
36
+ */
37
+ username?: string;
38
+ /**
39
+ * parameter for basic security
40
+ *
41
+ * @type {string}
42
+ * @memberof Configuration
43
+ */
44
+ password?: string;
45
+ /**
46
+ * parameter for oauth2 security
47
+ * @param name security name
48
+ * @param scopes oauth2 scope
49
+ * @memberof Configuration
50
+ */
51
+ accessToken?: string | ((name?: string, scopes?: string[]) => string);
52
+ /**
53
+ * override base path
54
+ *
55
+ * @type {string}
56
+ * @memberof Configuration
57
+ */
58
+ basePath?: string;
59
+ /**
60
+ * base options for axios calls
61
+ *
62
+ * @type {any}
63
+ * @memberof Configuration
64
+ */
65
+ baseOptions?: any;
66
+
67
+ constructor(param: ConfigurationParameters = {}) {
68
+ this.apiKey = param.apiKey;
69
+ this.username = param.username;
70
+ this.password = param.password;
71
+ this.accessToken = param.accessToken;
72
+ this.basePath = param.basePath;
73
+ this.baseOptions = param.baseOptions;
74
+ }
75
+ }
@@ -0,0 +1,58 @@
1
+ #!/bin/sh
2
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
+ #
4
+ # Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
5
+
6
+ git_user_id=$1
7
+ git_repo_id=$2
8
+ release_note=$3
9
+ git_host=$4
10
+
11
+ if [ "$git_host" = "" ]; then
12
+ git_host="github.com"
13
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14
+ fi
15
+
16
+ if [ "$git_user_id" = "" ]; then
17
+ git_user_id="GIT_USER_ID"
18
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
+ fi
20
+
21
+ if [ "$git_repo_id" = "" ]; then
22
+ git_repo_id="GIT_REPO_ID"
23
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
+ fi
25
+
26
+ if [ "$release_note" = "" ]; then
27
+ release_note="Minor update"
28
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29
+ fi
30
+
31
+ # Initialize the local directory as a Git repository
32
+ git init
33
+
34
+ # Adds the files in the local repository and stages them for commit.
35
+ git add .
36
+
37
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
38
+ git commit -m "$release_note"
39
+
40
+ # Sets the new remote
41
+ git_remote=`git remote`
42
+ if [ "$git_remote" = "" ]; then # git remote not defined
43
+
44
+ if [ "$GIT_TOKEN" = "" ]; then
45
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47
+ else
48
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
49
+ fi
50
+
51
+ fi
52
+
53
+ git pull origin master
54
+
55
+ # Pushes (Forces) the changes in the local repository up to the remote repository
56
+ echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57
+ git push origin master 2>&1 | grep -v 'To https'
58
+
@@ -0,0 +1,16 @@
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
+ export * from "./api";
16
+ export * from "./configuration";
@@ -0,0 +1 @@
1
+ export * from './inline-object';
@@ -0,0 +1,166 @@
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
+ /**
17
+ *
18
+ * @export
19
+ * @interface InlineObject
20
+ */
21
+ export interface InlineObject {
22
+ /**
23
+ * Audit log event unique identifier
24
+ * @type {string}
25
+ * @memberof InlineObject
26
+ */
27
+ id: string;
28
+ /**
29
+ * Audit log event country code
30
+ * @type {string}
31
+ * @memberof InlineObject
32
+ */
33
+ countryCode: CountryCodeEnum;
34
+ /**
35
+ * Audit log event payload
36
+ * @type {object}
37
+ * @memberof InlineObject
38
+ */
39
+ payload?: object;
40
+ /**
41
+ *
42
+ * @type {boolean}
43
+ * @memberof InlineObject
44
+ */
45
+ isImpersonated?: boolean;
46
+ /**
47
+ *
48
+ * @type {boolean}
49
+ * @memberof InlineObject
50
+ */
51
+ isSystem?: boolean;
52
+ /**
53
+ * Audit log event namespace (business related)
54
+ * @type {string}
55
+ * @memberof InlineObject
56
+ */
57
+ namespace: NamespaceEnum;
58
+ /**
59
+ * Audit log event namespace (technical related)
60
+ * @type {string}
61
+ * @memberof InlineObject
62
+ */
63
+ service: ServiceEnum;
64
+ /**
65
+ * Audit log event type
66
+ * @type {string}
67
+ * @memberof InlineObject
68
+ */
69
+ event?: EventEnum;
70
+ /**
71
+ * Audit log event environment
72
+ * @type {string}
73
+ * @memberof InlineObject
74
+ */
75
+ environment?: string;
76
+ /**
77
+ * Audit log event holdingId
78
+ * @type {string}
79
+ * @memberof InlineObject
80
+ */
81
+ holdingId?: string;
82
+ /**
83
+ * Audit log event companyId
84
+ * @type {string}
85
+ * @memberof InlineObject
86
+ */
87
+ companyId?: string;
88
+ /**
89
+ * Audit log event employeeId
90
+ * @type {string}
91
+ * @memberof InlineObject
92
+ */
93
+ employeeId?: string;
94
+ /**
95
+ * Audit log event individualId
96
+ * @type {string}
97
+ * @memberof InlineObject
98
+ */
99
+ individualId?: string;
100
+ /**
101
+ * Audit log event roleId
102
+ * @type {string}
103
+ * @memberof InlineObject
104
+ */
105
+ roleId?: string;
106
+ /**
107
+ * Audit log event userIp
108
+ * @type {string}
109
+ * @memberof InlineObject
110
+ */
111
+ userIp?: string;
112
+ /**
113
+ * Audit log event specialRole
114
+ * @type {string}
115
+ * @memberof InlineObject
116
+ */
117
+ specialRole?: string;
118
+ /**
119
+ * Audit log event email
120
+ * @type {string}
121
+ * @memberof InlineObject
122
+ */
123
+ email?: string;
124
+ }
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
+ * @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
+
165
+
166
+
@@ -0,0 +1,63 @@
1
+ import { v4 as uuidV4 } from 'uuid'
2
+ import { invert } from 'lodash'
3
+
4
+ import { DefaultApi } from './generated'
5
+ import {
6
+ CountryCodeEnum,
7
+ NamespaceEnum,
8
+ EventEnum,
9
+ ServiceEnum,
10
+ } from './generated/model'
11
+ import { AuditLogCreationData } from './interface'
12
+ import { ServiceName, Event } from '../types'
13
+
14
+ const api = new DefaultApi({
15
+ basePath: 'http://localhost:8090',
16
+ })
17
+
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
+ export async function auditLog(auditLogData: AuditLogCreationData) {
44
+ const {
45
+ countryCode,
46
+ namespace,
47
+ service,
48
+ event,
49
+ payload,
50
+ ...data
51
+ } = auditLogData
52
+
53
+ const dataToSend = {
54
+ ...data,
55
+ countryCode: serializeCountry(countryCode),
56
+ namespace: serializeNamespace(namespace),
57
+ service: serializeService(service),
58
+ event: serializeEvent(event),
59
+ payload,
60
+ }
61
+
62
+ return api.v1LogPost(dataToSend)
63
+ }
@@ -0,0 +1,6 @@
1
+ import { AuditLogData } from '..'
2
+
3
+ export type AuditLogCreationData = AuditLogData & {
4
+ id: string
5
+ timestamp: number
6
+ }
package/src/types.ts ADDED
@@ -0,0 +1,11 @@
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'
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es6",
4
+ "module": "commonjs",
5
+ "lib": ["es7", "esnext.asynciterable", "es2017"],
6
+ "sourceMap": true,
7
+ "outDir": "./dist",
8
+ "strict": true,
9
+ "noImplicitAny": true,
10
+ "strictNullChecks": true,
11
+ "noImplicitThis": true,
12
+ "alwaysStrict": true,
13
+ "noImplicitReturns": true,
14
+ "noFallthroughCasesInSwitch": true,
15
+ "moduleResolution": "node",
16
+ "baseUrl": "src",
17
+ "paths": {
18
+ "*": ["*"]
19
+ },
20
+ "esModuleInterop": true
21
+ },
22
+ "include": ["./src/**/*"],
23
+ "exclude": ["node_modules", "./src/__tests__/**/*"]
24
+ }
package/tslint.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "defaultSeverity": "error",
3
+ "extends": ["tslint:recommended", "tslint-config-prettier"],
4
+ "jsRules": {
5
+ "object-literal-sort-keys": false
6
+ },
7
+ "rules": {
8
+ "one-variable-per-declaration": false,
9
+ "interface-name": false
10
+ },
11
+ "rulesDirectory": []
12
+ }