@payfit/audit-log 2.0.0-rc.3 → 2.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.
Files changed (52) hide show
  1. package/.prettierrc +5 -0
  2. package/CHANGELOG.md +13 -0
  3. package/dist/index.d.ts +13 -7
  4. package/dist/index.js +55 -1
  5. package/dist/index.js.map +1 -0
  6. package/dist/transport/generated/api/default-api.d.ts +7 -7
  7. package/dist/transport/generated/api/default-api.js +156 -0
  8. package/dist/transport/generated/api/default-api.js.map +1 -0
  9. package/dist/transport/generated/api.js +26 -0
  10. package/dist/transport/generated/api.js.map +1 -0
  11. package/dist/transport/generated/base.d.ts +2 -2
  12. package/dist/transport/generated/base.js +64 -0
  13. package/dist/transport/generated/base.js.map +1 -0
  14. package/dist/transport/generated/configuration.d.ts +2 -22
  15. package/dist/transport/generated/configuration.js +27 -0
  16. package/dist/transport/generated/configuration.js.map +1 -0
  17. package/dist/transport/generated/index.d.ts +0 -1
  18. package/dist/transport/generated/index.js +27 -0
  19. package/dist/transport/generated/index.js.map +1 -0
  20. package/dist/transport/generated/model/index.js +14 -0
  21. package/dist/transport/generated/model/index.js.map +1 -0
  22. package/dist/transport/generated/model/inline-object.d.ts +20 -20
  23. package/dist/transport/generated/model/inline-object.js +15 -0
  24. package/dist/transport/generated/model/inline-object.js.map +1 -0
  25. package/dist/transport/implementation.d.ts +2 -1
  26. package/dist/transport/implementation.js +38 -0
  27. package/dist/transport/implementation.js.map +1 -0
  28. package/dist/transport/interface.d.ts +4 -4
  29. package/dist/transport/interface.js +3 -0
  30. package/dist/transport/interface.js.map +1 -0
  31. package/openapi-codegen-config.yml +6 -0
  32. package/openapitools.json +6 -0
  33. package/package.json +21 -45
  34. package/playground/index.ts +37 -0
  35. package/src/index.ts +205 -0
  36. package/src/transport/generated/.openapi-generator/VERSION +1 -0
  37. package/src/transport/generated/.openapi-generator-ignore +23 -0
  38. package/src/transport/generated/api/default-api.ts +132 -0
  39. package/src/transport/generated/api.ts +17 -0
  40. package/src/transport/generated/base.ts +70 -0
  41. package/src/transport/generated/configuration.ts +75 -0
  42. package/src/transport/generated/git_push.sh +58 -0
  43. package/src/transport/generated/index.ts +16 -0
  44. package/src/transport/generated/model/index.ts +1 -0
  45. package/src/transport/generated/model/inline-object.ts +144 -0
  46. package/src/transport/implementation.ts +27 -0
  47. package/src/transport/interface.ts +28 -0
  48. package/tsconfig.json +25 -0
  49. package/tslint.json +12 -0
  50. package/dist/index.mjs +0 -149
  51. package/dist/playground.d.ts +0 -1
  52. package/dist/transport/generated/common.d.ts +0 -65
@@ -0,0 +1,132 @@
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
+ // @ts-ignore
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: async (inlineObject: InlineObject, options: any = {}): Promise<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
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
59
+ localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
60
+ const needsSerialization = (typeof inlineObject !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
61
+ localVarRequestOptions.data = needsSerialization ? JSON.stringify(inlineObject !== undefined ? inlineObject : {}) : (inlineObject || "");
62
+
63
+ return {
64
+ url: globalImportUrl.format(localVarUrlObj),
65
+ options: localVarRequestOptions,
66
+ };
67
+ },
68
+ }
69
+ };
70
+
71
+ /**
72
+ * DefaultApi - functional programming interface
73
+ * @export
74
+ */
75
+ export const DefaultApiFp = function(configuration?: 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
+ async v1LogPost(inlineObject: InlineObject, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
85
+ const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).v1LogPost(inlineObject, options);
86
+ return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
87
+ const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
88
+ return axios.request(axiosRequestArgs);
89
+ };
90
+ },
91
+ }
92
+ };
93
+
94
+ /**
95
+ * DefaultApi - factory interface
96
+ * @export
97
+ */
98
+ export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
99
+ return {
100
+ /**
101
+ *
102
+ * @summary Creates Audit Log event
103
+ * @param {InlineObject} inlineObject
104
+ * @param {*} [options] Override http request option.
105
+ * @throws {RequiredError}
106
+ */
107
+ v1LogPost(inlineObject: InlineObject, options?: any): AxiosPromise<void> {
108
+ return DefaultApiFp(configuration).v1LogPost(inlineObject, options).then((request) => request(axios, basePath));
109
+ },
110
+ };
111
+ };
112
+
113
+ /**
114
+ * DefaultApi - object-oriented interface
115
+ * @export
116
+ * @class DefaultApi
117
+ * @extends {BaseAPI}
118
+ */
119
+ export class DefaultApi extends BaseAPI {
120
+ /**
121
+ *
122
+ * @summary Creates Audit Log event
123
+ * @param {InlineObject} inlineObject
124
+ * @param {*} [options] Override http request option.
125
+ * @throws {RequiredError}
126
+ * @memberof DefaultApi
127
+ */
128
+ public v1LogPost(inlineObject: InlineObject, options?: any) {
129
+ return DefaultApiFp(this.configuration).v1LogPost(inlineObject, options).then((request) => request(this.axios, this.basePath));
130
+ }
131
+
132
+ }
@@ -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:8090".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 | Promise<string> | ((name: string) => string) | ((name: string) => Promise<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 | Promise<string> | ((name: string) => string) | ((name: string) => Promise<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,144 @@
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?: string;
34
+ /**
35
+ * Audit log event payload
36
+ * @type {object}
37
+ * @memberof InlineObject
38
+ */
39
+ payload?: object;
40
+ /**
41
+ * id of the payfiter who performed the audit log action, if signed as.
42
+ * @type {string}
43
+ * @memberof InlineObject
44
+ */
45
+ internalId?: string;
46
+ /**
47
+ * Tells whether the logged action has been made by the system
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: string;
58
+ /**
59
+ * Audit log event namespace (technical related)
60
+ * @type {string}
61
+ * @memberof InlineObject
62
+ */
63
+ service: string;
64
+ /**
65
+ * Audit log event type
66
+ * @type {string}
67
+ * @memberof InlineObject
68
+ */
69
+ event: string;
70
+ /**
71
+ * Audit log target
72
+ * @type {string}
73
+ * @memberof InlineObject
74
+ */
75
+ target: string;
76
+ /**
77
+ * Audit log event environment, only required when in todd context
78
+ * @type {string}
79
+ * @memberof InlineObject
80
+ */
81
+ environment?: string;
82
+ /**
83
+ * holdingId of the account performing the event
84
+ * @type {string}
85
+ * @memberof InlineObject
86
+ */
87
+ holdingId?: string;
88
+ /**
89
+ * companyId of the account performing the event
90
+ * @type {string}
91
+ * @memberof InlineObject
92
+ */
93
+ companyId?: string;
94
+ /**
95
+ * employeeId of the account performing the event
96
+ * @type {string}
97
+ * @memberof InlineObject
98
+ */
99
+ employeeId?: string;
100
+ /**
101
+ * individualId of the account performing the event
102
+ * @type {string}
103
+ * @memberof InlineObject
104
+ */
105
+ individualId?: string;
106
+ /**
107
+ * roleId of the account performing the event
108
+ * @type {string}
109
+ * @memberof InlineObject
110
+ */
111
+ roleId?: string;
112
+ /**
113
+ * userIp of the account performing the event
114
+ * @type {string}
115
+ * @memberof InlineObject
116
+ */
117
+ userIp?: string;
118
+ /**
119
+ * specialRole of the account performing the event
120
+ * @type {string}
121
+ * @memberof InlineObject
122
+ */
123
+ specialRole?: string;
124
+ /**
125
+ * email of the account performing the event
126
+ * @type {string}
127
+ * @memberof InlineObject
128
+ */
129
+ email?: string;
130
+ /**
131
+ * Audit log event scope
132
+ * @type {object}
133
+ * @memberof InlineObject
134
+ */
135
+ scope?: object;
136
+ /**
137
+ * Audit log event timestamp unix format
138
+ * @type {number}
139
+ * @memberof InlineObject
140
+ */
141
+ timestamp: number;
142
+ }
143
+
144
+
@@ -0,0 +1,27 @@
1
+ import { DefaultApi } from './generated'
2
+ import { InlineObject } from './generated/model'
3
+
4
+ import { IAuditLogTransport } from './interface'
5
+
6
+ export class Transport implements IAuditLogTransport {
7
+ api: DefaultApi
8
+
9
+ constructor(protected apiUrl: string) {
10
+ this.api = new DefaultApi({
11
+ basePath: this.apiUrl,
12
+ })
13
+ }
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
+ }
22
+
23
+ const message = err.response?.data || err.message
24
+ throw new Error(message)
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,28 @@
1
+ import { IAuditLogData } from '..'
2
+
3
+ export type IAuditLogCreationData = {
4
+ id: string
5
+ timestamp: number
6
+ environment: string
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
24
+ }
25
+
26
+ export interface IAuditLogTransport {
27
+ create: (data: IAuditLogCreationData) => Promise<void>
28
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "target": "es6",
5
+ "module": "commonjs",
6
+ "lib": ["es7", "esnext.asynciterable", "es2017"],
7
+ "sourceMap": true,
8
+ "outDir": "./dist",
9
+ "strict": true,
10
+ "noImplicitAny": true,
11
+ "strictNullChecks": true,
12
+ "noImplicitThis": true,
13
+ "alwaysStrict": true,
14
+ "noImplicitReturns": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "moduleResolution": "node",
17
+ "baseUrl": "src",
18
+ "paths": {
19
+ "*": ["*"]
20
+ },
21
+ "esModuleInterop": true
22
+ },
23
+ "include": ["./src/**/*"],
24
+ "exclude": ["node_modules", "./src/__tests__/**/*"]
25
+ }
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
+ }