@payfit/audit-log 1.0.0-alpha8 → 1.0.0-rc.100
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/README.md +92 -0
- package/dist/index.d.ts +27 -8
- package/dist/index.js +1 -30
- package/dist/index.mjs +149 -0
- package/dist/playground.d.ts +1 -0
- package/dist/transport/generated/api/default-api.d.ts +7 -7
- package/dist/transport/generated/base.d.ts +2 -2
- package/dist/transport/generated/common.d.ts +65 -0
- package/dist/transport/generated/configuration.d.ts +24 -4
- package/dist/transport/generated/index.d.ts +1 -0
- package/dist/transport/generated/model/inline-object.d.ts +36 -18
- package/dist/transport/implementation.d.ts +4 -4
- package/dist/transport/interface.d.ts +18 -3
- package/package.json +46 -18
- package/.prettierrc +0 -5
- package/dist/index.js.map +0 -1
- package/dist/transport/generated/api/default-api.js +0 -131
- package/dist/transport/generated/api/default-api.js.map +0 -1
- package/dist/transport/generated/api.js +0 -19
- package/dist/transport/generated/api.js.map +0 -1
- package/dist/transport/generated/base.js +0 -63
- package/dist/transport/generated/base.js.map +0 -1
- package/dist/transport/generated/configuration.js +0 -26
- package/dist/transport/generated/configuration.js.map +0 -1
- package/dist/transport/generated/index.js +0 -20
- package/dist/transport/generated/index.js.map +0 -1
- package/dist/transport/generated/model/index.js +0 -3
- package/dist/transport/generated/model/index.js.map +0 -1
- package/dist/transport/generated/model/inline-object.js +0 -15
- package/dist/transport/generated/model/inline-object.js.map +0 -1
- package/dist/transport/implementation.js +0 -39
- package/dist/transport/implementation.js.map +0 -1
- package/dist/transport/interface.js +0 -3
- package/dist/transport/interface.js.map +0 -1
- package/openapi-codegen-config.yml +0 -6
- package/playground/index.ts +0 -26
- package/src/index.ts +0 -120
- package/src/transport/generated/.openapi-generator/VERSION +0 -1
- package/src/transport/generated/.openapi-generator-ignore +0 -23
- package/src/transport/generated/api/default-api.ts +0 -131
- package/src/transport/generated/api.ts +0 -17
- package/src/transport/generated/base.ts +0 -70
- package/src/transport/generated/configuration.ts +0 -75
- package/src/transport/generated/git_push.sh +0 -58
- package/src/transport/generated/index.ts +0 -16
- package/src/transport/generated/model/index.ts +0 -1
- package/src/transport/generated/model/inline-object.ts +0 -126
- package/src/transport/implementation.ts +0 -23
- package/src/transport/interface.ts +0 -12
- package/tsconfig.json +0 -25
- package/tslint.json +0 -12
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Audit logs SDK
|
|
2
|
+
|
|
3
|
+
The SDK is an npm package that makes it easier to call the Audit Log API.
|
|
4
|
+
|
|
5
|
+
## Using the SDK in your project
|
|
6
|
+
|
|
7
|
+
First, install it :
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i @payfit/audit-log
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then, you must instanciate a client :
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { AuditLogger } from '@payfit/audit-log'
|
|
17
|
+
|
|
18
|
+
const logger = new AuditLogger({
|
|
19
|
+
apiUrl: 'http://localhost:8090',
|
|
20
|
+
environment: 'an-environment-name',
|
|
21
|
+
service: 'the-name-of-the-service',
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
You can finally write an audit log:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
logger.log({
|
|
29
|
+
namespace: 'payroll',
|
|
30
|
+
target: 'employee.bonus',
|
|
31
|
+
event: 'create',
|
|
32
|
+
payload: {
|
|
33
|
+
amount: 200,
|
|
34
|
+
},
|
|
35
|
+
account: {
|
|
36
|
+
internalId: 'an internal id',
|
|
37
|
+
individualId: 'an invidiaul id',
|
|
38
|
+
employeeId: 'an employee id',
|
|
39
|
+
},
|
|
40
|
+
scope: {
|
|
41
|
+
employeeId: 'another employee id',
|
|
42
|
+
companyId: 'a company id',
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Contributing
|
|
48
|
+
|
|
49
|
+
### Building the SDK
|
|
50
|
+
|
|
51
|
+
In order to keep synced with the actual API, the API calls from the SDK are autogenerated by [openapi-generator](https://github.com/OpenAPITools/openapi-generator). It uses the [openapi.json](../pkg/broker/v1/swagger/openapi.json) file and builds an axios client that sends the correct requests accordingly to that file.
|
|
52
|
+
|
|
53
|
+
To build it, simply run
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npm run build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
from the sdk folder (where the `package.json` is located).
|
|
60
|
+
|
|
61
|
+
### Testing
|
|
62
|
+
|
|
63
|
+
For now, no unit tests have been written, but it should arrive soon !
|
|
64
|
+
|
|
65
|
+
### Playing around with he SDK
|
|
66
|
+
|
|
67
|
+
Could it be for testing some changes you made, or just to discover how to use the SDK, there is a [playground](./playground) at your disposal.
|
|
68
|
+
|
|
69
|
+
It uses the current code in the repository, not the published one, so you don't have to `npm publish` or `npm link` to make it work 🙂
|
|
70
|
+
|
|
71
|
+
To run it, simply run from the `sdk` folder:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
npm run start:playground
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Publishing
|
|
78
|
+
|
|
79
|
+
For now, there is no automated publishing from CI, so you have to publish it manually.
|
|
80
|
+
|
|
81
|
+
To do so, simply bump the `version` field in the `package.json` file, and run
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
npm publish
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Code organisation
|
|
88
|
+
|
|
89
|
+
The code is mainly split into 2 parts:
|
|
90
|
+
|
|
91
|
+
- The transport part, whose only goal is to tell how to communicate with the API, i.e it abstracts the communication layer.
|
|
92
|
+
- The logic part, which tells how to build an audit log.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The allowed Namespaces for the AuditLog
|
|
3
|
+
*/
|
|
4
|
+
export type AuditNamespaces = 'employee' | 'company' | 'permissions' | 'absence' | 'expense' | 'payments' | 'auth' | 'billing' | 'modules' | 'integrations' | 'partnerApi' | 'donation' | 'notificationSettings' | 'people' | 'subscriptions' | 'organization' | 'declarations' | 'pricing' | 'payroll' | 'jetlang' | 'files';
|
|
5
|
+
/**
|
|
6
|
+
* The allowed targets for the AuditLog
|
|
7
|
+
*/
|
|
8
|
+
export type AuditTargets = 'reporting' | 'employee' | 'employee.settings' | 'employee-request' | 'company' | 'company.billings' | 'company.billing' | 'company.variables' | 'company.settings' | 'company.emails' | 'company.addons' | 'company.plans' | 'company.modules' | 'declaration.metadata' | 'user.role' | 'user.account' | 'user.primaryEmail' | 'user.secondaryEmail' | 'user.locale' | 'user.notificationSettings' | 'user.mfa' | 'role' | 'team' | 'department' | 'workflow' | 'integration' | 'apiAccess' | 'individual' | 'association' | 'association.archived' | 'donation' | 'donation.amount' | 'donation.auth.partner.portal' | 'donation.company.onboarding' | 'donation.taxReceipt' | 'donationPayment.status' | 'people.document.comments' | 'people.document.notifications' | 'people.document.reactions' | 'people.document.status' | 'people.document.answers' | 'people.oneOne' | 'people.campaign' | 'people.assessment' | 'people.assessment.360details' | 'people.assessment.managerRequests' | 'people.assessment.manager' | 'people.assessment.answers' | 'people.assessment.feedbacks' | 'iban' | 'salary-payments.connect' | 'salary-payments.pay.url' | 'advance-salary-payments.pay.url' | 'variable' | 'jetlang-data' | 'access-logs' | 'event' | 'topic' | 'file' | 'file.presigned-url' | 'archive' | 'payslip.merge';
|
|
9
|
+
/**
|
|
10
|
+
* The allowed Events for the AuditLog
|
|
11
|
+
*/
|
|
12
|
+
export type AuditEvents = 'create' | 'update' | 'share' | 'delete' | 'view' | 'sign' | 'signin' | 'signinFail' | 'signinAs' | 'logout' | 'updateCurrentAccount' | 'merge' | 'disable' | 'sendResetPasswordLink' | 'enable' | 'verify' | 'read' | 'write' | 'subscribe' | 'consume' | 'setup';
|
|
1
13
|
/**
|
|
2
14
|
* Data to audit log.
|
|
3
15
|
*/
|
|
@@ -6,17 +18,22 @@ export interface IAuditLogData {
|
|
|
6
18
|
* The data specific to the audit log.
|
|
7
19
|
* For example, if we add a bonus to an employee, it could contain the amount, the impacted employeeId, etc...
|
|
8
20
|
*/
|
|
9
|
-
payload?:
|
|
21
|
+
payload?: Record<string, unknown>;
|
|
10
22
|
/**
|
|
11
23
|
* The buisness domain impacted.
|
|
12
24
|
* e.g documents, authentication, ...
|
|
13
25
|
*/
|
|
14
|
-
namespace:
|
|
26
|
+
namespace: AuditNamespaces;
|
|
15
27
|
/**
|
|
16
28
|
* The name of the event.
|
|
17
|
-
* e.g. signIn, passwordUpdated,
|
|
29
|
+
* e.g. signIn, passwordUpdated, ...
|
|
18
30
|
*/
|
|
19
|
-
event:
|
|
31
|
+
event: AuditEvents;
|
|
32
|
+
/**
|
|
33
|
+
* The target of event.
|
|
34
|
+
* e.g. user.settings, employee.bonuses, ...
|
|
35
|
+
*/
|
|
36
|
+
target: AuditTargets | string;
|
|
20
37
|
/**
|
|
21
38
|
* The data that describes who did perform the logged action.
|
|
22
39
|
*/
|
|
@@ -29,7 +46,7 @@ export interface IAuditLogData {
|
|
|
29
46
|
/**
|
|
30
47
|
* Data used to indentify who performed an action
|
|
31
48
|
*/
|
|
32
|
-
export
|
|
49
|
+
export type IAuditLogAuthData = {
|
|
33
50
|
/**
|
|
34
51
|
* The id of the payfiter that did the action if it has been made during a siginAs
|
|
35
52
|
*/
|
|
@@ -37,7 +54,7 @@ export declare type IAuditLogAuthData = {
|
|
|
37
54
|
holdingId?: string;
|
|
38
55
|
companyId?: string;
|
|
39
56
|
employeeId?: string;
|
|
40
|
-
individualId
|
|
57
|
+
individualId?: string;
|
|
41
58
|
roleId?: string;
|
|
42
59
|
/**
|
|
43
60
|
*
|
|
@@ -58,11 +75,13 @@ export declare type IAuditLogAuthData = {
|
|
|
58
75
|
* Data used to "scope" the audit log.
|
|
59
76
|
* Might be useful to retrieve all actions performed in a holding, a company, or on an employee.
|
|
60
77
|
*/
|
|
61
|
-
export
|
|
78
|
+
export type IAuditLogScope = {
|
|
62
79
|
holdingId: string;
|
|
63
80
|
} | {
|
|
64
81
|
companyId: string;
|
|
65
82
|
employeeId?: string;
|
|
83
|
+
} | {
|
|
84
|
+
individualId: string;
|
|
66
85
|
} | null;
|
|
67
86
|
export interface IAuditLogger {
|
|
68
87
|
log: (data: IAuditLogData) => Promise<void>;
|
|
@@ -76,5 +95,5 @@ export declare class AuditLogger implements IAuditLogger {
|
|
|
76
95
|
protected params: IAuditLoggerInitialization;
|
|
77
96
|
private transport;
|
|
78
97
|
constructor(params: IAuditLoggerInitialization);
|
|
79
|
-
log(data: IAuditLogData): Promise<void>;
|
|
98
|
+
log({ scope, account, ...data }: IAuditLogData): Promise<void>;
|
|
80
99
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const uuid_1 = require("uuid");
|
|
12
|
-
const implementation_1 = require("./transport/implementation");
|
|
13
|
-
class AuditLogger {
|
|
14
|
-
constructor(params) {
|
|
15
|
-
this.params = params;
|
|
16
|
-
this.transport = new implementation_1.Transport(params.apiUrl);
|
|
17
|
-
}
|
|
18
|
-
log(data) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const uuid = uuid_1.v4();
|
|
21
|
-
const { environment, service } = this.params;
|
|
22
|
-
const timestamp = new Date().getTime();
|
|
23
|
-
const log = Object.assign({}, data, { service, id: uuid, environment,
|
|
24
|
-
timestamp });
|
|
25
|
-
yield this.transport.create(log);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.AuditLogger = AuditLogger;
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var d=Object.defineProperty;var P=(s,e,t)=>e in s?d(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var n=(s,e,t)=>(P(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("uuid"),h=require("axios"),p="http://localhost:8090".replace(/\/+$/,"");class f{constructor(e,t=p,r=h){n(this,"basePath");n(this,"axios");n(this,"configuration");this.basePath=t,this.axios=r,e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}}class g extends Error{constructor(t,r){super(r);n(this,"field");n(this,"name","RequiredError");this.field=t}}const A="https://example.com",w=function(s,e,t){if(t==null)throw new g(e,`Required parameter ${e} was null or undefined when calling ${s}.`)},b=function(s,...e){const t=new URLSearchParams(s.search);for(const r of e)for(const o in r)if(Array.isArray(r[o])){t.delete(o);for(const a of r[o])t.append(o,a)}else t.set(o,r[o]);s.search=t.toString()},x=function(s,e,t){const r=typeof s!="string";return(r&&t&&t.isJsonMime?t.isJsonMime(e.headers["Content-Type"]):r)?JSON.stringify(s!==void 0?s:{}):s||""},y=function(s){return s.pathname+s.search+s.hash},L=function(s,e,t,r){return(o=e,a=t)=>{const i={...s.options,url:((r==null?void 0:r.basePath)||a)+s.url};return o.request(i)}},S=function(s){return{v1LogPost:async(e,t={})=>{w("v1LogPost","inlineObject",e);const r="/v1/log",o=new URL(r,A);let a;s&&(a=s.baseOptions);const i={method:"POST",...a,...t},c={},l={};c["Content-Type"]="application/json",b(o,l);let u=a&&a.headers?a.headers:{};return i.headers={...c,...u,...t.headers},i.data=x(e,i,s),{url:y(o),options:i}}}},E=function(s){const e=S(s);return{async v1LogPost(t,r){const o=await e.v1LogPost(t,r);return L(o,h,p,s)}}};class v extends f{v1LogPost(e,t){return E(this.configuration).v1LogPost(e,t).then(r=>r(this.axios,this.basePath))}}const R=s=>"isAxiosError"in s&&s.isAxiosError&&s instanceof Error;class j{constructor(e){n(this,"apiUrl");n(this,"api");this.apiUrl=e,this.api=new v({basePath:this.apiUrl,isJsonMime(t){const r=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return t!==null&&(r.test(t)||t.toLowerCase()==="application/json-patch+json")}})}async create(e){var t;try{await this.api.v1LogPost(e,{timeout:5e3})}catch(r){if(!R(r))throw r;const o=((t=r.response)==null?void 0:t.data)||r.message;throw new Error(o)}}}class q{constructor(e){n(this,"params");n(this,"transport");this.params=e,this.transport=new j(e.apiUrl)}async log({scope:e,account:t,...r}){const o=m.v4(),{environment:a,service:i}=this.params,c=Math.floor(Date.now()/1e3),l={...r,...t,service:i,id:o,environment:a,timestamp:c,...e&&{scope:e}};await this.transport.create(l)}}exports.AuditLogger=q;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var P = (s, e, t) => e in s ? u(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var n = (s, e, t) => (P(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { v4 as m } from "uuid";
|
|
5
|
+
import l from "axios";
|
|
6
|
+
const p = "http://localhost:8090".replace(/\/+$/, "");
|
|
7
|
+
class f {
|
|
8
|
+
constructor(e, t = p, o = l) {
|
|
9
|
+
n(this, "basePath");
|
|
10
|
+
n(this, "axios");
|
|
11
|
+
n(this, "configuration");
|
|
12
|
+
this.basePath = t, this.axios = o, e && (this.configuration = e, this.basePath = e.basePath || this.basePath);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
class A extends Error {
|
|
16
|
+
constructor(t, o) {
|
|
17
|
+
super(o);
|
|
18
|
+
n(this, "field");
|
|
19
|
+
n(this, "name", "RequiredError");
|
|
20
|
+
this.field = t;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const w = "https://example.com", x = function(s, e, t) {
|
|
24
|
+
if (t == null)
|
|
25
|
+
throw new A(e, `Required parameter ${e} was null or undefined when calling ${s}.`);
|
|
26
|
+
}, g = function(s, ...e) {
|
|
27
|
+
const t = new URLSearchParams(s.search);
|
|
28
|
+
for (const o of e)
|
|
29
|
+
for (const r in o)
|
|
30
|
+
if (Array.isArray(o[r])) {
|
|
31
|
+
t.delete(r);
|
|
32
|
+
for (const a of o[r])
|
|
33
|
+
t.append(r, a);
|
|
34
|
+
} else
|
|
35
|
+
t.set(r, o[r]);
|
|
36
|
+
s.search = t.toString();
|
|
37
|
+
}, b = function(s, e, t) {
|
|
38
|
+
const o = typeof s != "string";
|
|
39
|
+
return (o && t && t.isJsonMime ? t.isJsonMime(e.headers["Content-Type"]) : o) ? JSON.stringify(s !== void 0 ? s : {}) : s || "";
|
|
40
|
+
}, y = function(s) {
|
|
41
|
+
return s.pathname + s.search + s.hash;
|
|
42
|
+
}, E = function(s, e, t, o) {
|
|
43
|
+
return (r = e, a = t) => {
|
|
44
|
+
const i = { ...s.options, url: ((o == null ? void 0 : o.basePath) || a) + s.url };
|
|
45
|
+
return r.request(i);
|
|
46
|
+
};
|
|
47
|
+
}, L = function(s) {
|
|
48
|
+
return {
|
|
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: async (e, t = {}) => {
|
|
57
|
+
x("v1LogPost", "inlineObject", e);
|
|
58
|
+
const o = "/v1/log", r = new URL(o, w);
|
|
59
|
+
let a;
|
|
60
|
+
s && (a = s.baseOptions);
|
|
61
|
+
const i = { method: "POST", ...a, ...t }, c = {}, h = {};
|
|
62
|
+
c["Content-Type"] = "application/json", g(r, h);
|
|
63
|
+
let d = a && a.headers ? a.headers : {};
|
|
64
|
+
return i.headers = { ...c, ...d, ...t.headers }, i.data = b(e, i, s), {
|
|
65
|
+
url: y(r),
|
|
66
|
+
options: i
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}, S = function(s) {
|
|
71
|
+
const e = L(s);
|
|
72
|
+
return {
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @summary Creates Audit Log event
|
|
76
|
+
* @param {InlineObject} inlineObject
|
|
77
|
+
* @param {*} [options] Override http request option.
|
|
78
|
+
* @throws {RequiredError}
|
|
79
|
+
*/
|
|
80
|
+
async v1LogPost(t, o) {
|
|
81
|
+
const r = await e.v1LogPost(t, o);
|
|
82
|
+
return E(r, l, p, s);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
class v extends f {
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @summary Creates Audit Log event
|
|
90
|
+
* @param {InlineObject} inlineObject
|
|
91
|
+
* @param {*} [options] Override http request option.
|
|
92
|
+
* @throws {RequiredError}
|
|
93
|
+
* @memberof DefaultApi
|
|
94
|
+
*/
|
|
95
|
+
v1LogPost(e, t) {
|
|
96
|
+
return S(this.configuration).v1LogPost(e, t).then((o) => o(this.axios, this.basePath));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const R = (s) => "isAxiosError" in s && s.isAxiosError && s instanceof Error;
|
|
100
|
+
class U {
|
|
101
|
+
constructor(e) {
|
|
102
|
+
n(this, "apiUrl");
|
|
103
|
+
n(this, "api");
|
|
104
|
+
this.apiUrl = e, this.api = new v({
|
|
105
|
+
basePath: this.apiUrl,
|
|
106
|
+
isJsonMime(t) {
|
|
107
|
+
const o = new RegExp(
|
|
108
|
+
// eslint-disable-next-line no-control-regex
|
|
109
|
+
"^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$",
|
|
110
|
+
"i"
|
|
111
|
+
);
|
|
112
|
+
return t !== null && (o.test(t) || t.toLowerCase() === "application/json-patch+json");
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async create(e) {
|
|
117
|
+
var t;
|
|
118
|
+
try {
|
|
119
|
+
await this.api.v1LogPost(e, { timeout: 5e3 });
|
|
120
|
+
} catch (o) {
|
|
121
|
+
if (!R(o))
|
|
122
|
+
throw o;
|
|
123
|
+
const r = ((t = o.response) == null ? void 0 : t.data) || o.message;
|
|
124
|
+
throw new Error(r);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
class O {
|
|
129
|
+
constructor(e) {
|
|
130
|
+
n(this, "params");
|
|
131
|
+
n(this, "transport");
|
|
132
|
+
this.params = e, this.transport = new U(e.apiUrl);
|
|
133
|
+
}
|
|
134
|
+
async log({ scope: e, account: t, ...o }) {
|
|
135
|
+
const r = m(), { environment: a, service: i } = this.params, c = Math.floor(Date.now() / 1e3), h = {
|
|
136
|
+
...o,
|
|
137
|
+
...t,
|
|
138
|
+
service: i,
|
|
139
|
+
id: r,
|
|
140
|
+
environment: a,
|
|
141
|
+
timestamp: c,
|
|
142
|
+
...e && { scope: e }
|
|
143
|
+
};
|
|
144
|
+
await this.transport.create(h);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
O as AuditLogger
|
|
149
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* https://openapi-generator.tech
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
|
-
import { AxiosPromise, AxiosInstance } from 'axios';
|
|
12
|
+
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
13
13
|
import { Configuration } from '../configuration';
|
|
14
14
|
import { RequestArgs, BaseAPI } from '../base';
|
|
15
15
|
import { InlineObject } from '../model';
|
|
@@ -17,7 +17,7 @@ import { InlineObject } from '../model';
|
|
|
17
17
|
* DefaultApi - axios parameter creator
|
|
18
18
|
* @export
|
|
19
19
|
*/
|
|
20
|
-
export declare const DefaultApiAxiosParamCreator: (configuration?: Configuration
|
|
20
|
+
export declare const DefaultApiAxiosParamCreator: (configuration?: Configuration) => {
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @summary Creates Audit Log event
|
|
@@ -25,13 +25,13 @@ export declare const DefaultApiAxiosParamCreator: (configuration?: Configuration
|
|
|
25
25
|
* @param {*} [options] Override http request option.
|
|
26
26
|
* @throws {RequiredError}
|
|
27
27
|
*/
|
|
28
|
-
v1LogPost(inlineObject: InlineObject, options?:
|
|
28
|
+
v1LogPost: (inlineObject: InlineObject, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* DefaultApi - functional programming interface
|
|
32
32
|
* @export
|
|
33
33
|
*/
|
|
34
|
-
export declare const DefaultApiFp: (configuration?: Configuration
|
|
34
|
+
export declare const DefaultApiFp: (configuration?: Configuration) => {
|
|
35
35
|
/**
|
|
36
36
|
*
|
|
37
37
|
* @summary Creates Audit Log event
|
|
@@ -39,13 +39,13 @@ export declare const DefaultApiFp: (configuration?: Configuration | undefined) =
|
|
|
39
39
|
* @param {*} [options] Override http request option.
|
|
40
40
|
* @throws {RequiredError}
|
|
41
41
|
*/
|
|
42
|
-
v1LogPost(inlineObject: InlineObject, options?:
|
|
42
|
+
v1LogPost(inlineObject: InlineObject, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>>;
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
45
|
* DefaultApi - factory interface
|
|
46
46
|
* @export
|
|
47
47
|
*/
|
|
48
|
-
export declare const DefaultApiFactory: (configuration?: Configuration
|
|
48
|
+
export declare const DefaultApiFactory: (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) => {
|
|
49
49
|
/**
|
|
50
50
|
*
|
|
51
51
|
* @summary Creates Audit Log event
|
|
@@ -70,5 +70,5 @@ export declare class DefaultApi extends BaseAPI {
|
|
|
70
70
|
* @throws {RequiredError}
|
|
71
71
|
* @memberof DefaultApi
|
|
72
72
|
*/
|
|
73
|
-
v1LogPost(inlineObject: InlineObject, options?:
|
|
73
|
+
v1LogPost(inlineObject: InlineObject, options?: AxiosRequestConfig): Promise<globalAxios.AxiosResponse<void, any>>;
|
|
74
74
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
12
|
import { Configuration } from "./configuration";
|
|
13
|
-
import { AxiosInstance } from 'axios';
|
|
13
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
14
14
|
export declare const BASE_PATH: string;
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
@@ -29,7 +29,7 @@ export declare const COLLECTION_FORMATS: {
|
|
|
29
29
|
*/
|
|
30
30
|
export interface RequestArgs {
|
|
31
31
|
url: string;
|
|
32
|
-
options:
|
|
32
|
+
options: AxiosRequestConfig;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
*
|
|
@@ -0,0 +1,65 @@
|
|
|
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 { RequestArgs } from "./base";
|
|
14
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
*/
|
|
19
|
+
export declare const DUMMY_BASE_URL = "https://example.com";
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @throws {RequiredError}
|
|
23
|
+
* @export
|
|
24
|
+
*/
|
|
25
|
+
export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @export
|
|
29
|
+
*/
|
|
30
|
+
export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @export
|
|
34
|
+
*/
|
|
35
|
+
export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @export
|
|
39
|
+
*/
|
|
40
|
+
export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @export
|
|
44
|
+
*/
|
|
45
|
+
export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
*/
|
|
50
|
+
export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @export
|
|
54
|
+
*/
|
|
55
|
+
export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @export
|
|
59
|
+
*/
|
|
60
|
+
export declare const toPathString: (url: URL) => string;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @export
|
|
64
|
+
*/
|
|
65
|
+
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
|
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
12
|
export interface ConfigurationParameters {
|
|
13
|
-
apiKey?: string | ((name: string) => string);
|
|
13
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
14
14
|
username?: string;
|
|
15
15
|
password?: string;
|
|
16
|
-
accessToken?: string | ((name?: string, scopes?: string[]) => string);
|
|
16
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
17
17
|
basePath?: string;
|
|
18
18
|
baseOptions?: any;
|
|
19
|
+
formDataCtor?: new () => any;
|
|
19
20
|
}
|
|
20
21
|
export declare class Configuration {
|
|
21
22
|
/**
|
|
@@ -23,7 +24,7 @@ export declare class Configuration {
|
|
|
23
24
|
* @param name security name
|
|
24
25
|
* @memberof Configuration
|
|
25
26
|
*/
|
|
26
|
-
apiKey?: string | ((name: string) => string);
|
|
27
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
27
28
|
/**
|
|
28
29
|
* parameter for basic security
|
|
29
30
|
*
|
|
@@ -44,7 +45,7 @@ export declare class Configuration {
|
|
|
44
45
|
* @param scopes oauth2 scope
|
|
45
46
|
* @memberof Configuration
|
|
46
47
|
*/
|
|
47
|
-
accessToken?: string | ((name?: string, scopes?: string[]) => string);
|
|
48
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
48
49
|
/**
|
|
49
50
|
* override base path
|
|
50
51
|
*
|
|
@@ -59,5 +60,24 @@ export declare class Configuration {
|
|
|
59
60
|
* @memberof Configuration
|
|
60
61
|
*/
|
|
61
62
|
baseOptions?: any;
|
|
63
|
+
/**
|
|
64
|
+
* The FormData constructor that will be used to create multipart form data
|
|
65
|
+
* requests. You can inject this here so that execution environments that
|
|
66
|
+
* do not support the FormData class can still run the generated client.
|
|
67
|
+
*
|
|
68
|
+
* @type {new () => FormData}
|
|
69
|
+
*/
|
|
70
|
+
formDataCtor?: new () => any;
|
|
62
71
|
constructor(param?: ConfigurationParameters);
|
|
72
|
+
/**
|
|
73
|
+
* Check if the given MIME is a JSON MIME.
|
|
74
|
+
* JSON MIME examples:
|
|
75
|
+
* application/json
|
|
76
|
+
* application/json; charset=UTF8
|
|
77
|
+
* APPLICATION/JSON
|
|
78
|
+
* application/vnd.company+json
|
|
79
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
80
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
81
|
+
*/
|
|
82
|
+
isJsonMime(mime: string): boolean;
|
|
63
83
|
}
|