@meistrari/audit-sdk 0.0.0 → 0.1.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.
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -9
- package/dist/index.d.ts.map +1 -1
- package/package.json +28 -28
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAA;AAEjD,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,WAAW,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,WAAW;IACpB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,UAAU,CAAQ;gBAEd,MAAM,EAAE,iBAAiB;IAM/B,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU;IAI1C,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE;IA6CvD,OAAO,CAAC,UAAU;YAaJ,KAAK;CAGtB;AAED,qBAAa,UAAW,SAAQ,KAAK;IACG,OAAO,CAAC,EAAE,OAAO;gBAAzC,OAAO,EAAE,MAAM,EAAS,OAAO,CAAC,EAAE,OAAO,YAAA;CAIxD"}
|
package/dist/client.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pino from '@meistrari/logger';
|
|
2
|
+
const logger = pino();
|
|
1
3
|
export class AuditClient {
|
|
2
4
|
constructor(config) {
|
|
3
5
|
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
@@ -14,7 +16,7 @@ export class AuditClient {
|
|
|
14
16
|
const response = await fetch(`${this.baseUrl}/v1/events`, {
|
|
15
17
|
method: 'POST',
|
|
16
18
|
headers: {
|
|
17
|
-
Authorization: `Bearer ${dataToken}`,
|
|
19
|
+
'Authorization': `Bearer ${dataToken}`,
|
|
18
20
|
'Content-Type': 'application/json',
|
|
19
21
|
},
|
|
20
22
|
body: JSON.stringify({ events }),
|
|
@@ -40,7 +42,7 @@ export class AuditClient {
|
|
|
40
42
|
}
|
|
41
43
|
lastError = error;
|
|
42
44
|
}
|
|
43
|
-
await this.sleep(
|
|
45
|
+
await this.sleep(2 ** attempt * 1000);
|
|
44
46
|
}
|
|
45
47
|
this.logFailure(events, lastError);
|
|
46
48
|
}
|
|
@@ -50,15 +52,13 @@ export class AuditClient {
|
|
|
50
52
|
service: 'audit-sdk',
|
|
51
53
|
message: 'Failed to send audit events after retries',
|
|
52
54
|
event_count: events.length,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
error: error?.message,
|
|
56
|
-
timestamp: new Date().toISOString(),
|
|
55
|
+
events,
|
|
56
|
+
error,
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
logger.error(payload);
|
|
59
59
|
}
|
|
60
|
-
sleep(ms) {
|
|
61
|
-
|
|
60
|
+
async sleep(ms) {
|
|
61
|
+
await new Promise(resolve => setTimeout(resolve, ms));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
export class AuditError extends Error {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
"name": "@meistrari/audit-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"description": "",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/meistrari/audit-service.git"
|
|
10
|
+
},
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.json",
|
|
17
|
+
"postinstall": "mise-en-place postinstall",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@meistrari/mise-en-place": "2.10.2",
|
|
25
|
+
"typescript": "^5.3.3"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@meistrari/logger": "2.1.3"
|
|
29
|
+
}
|
|
30
30
|
}
|