@payfit/audit-log 2.0.0-rc.4 → 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
package/dist/index.mjs DELETED
@@ -1,149 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,65 +0,0 @@
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>;