@enonic-types/lib-auditlog 0.1.1 → 7.11.0-B3
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 +4 -4
- package/auditlog.d.ts +102 -92
- package/package.json +35 -32
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm i --save-dev @enonic/lib-auditlog
|
|
8
|
+
npm i --save-dev @enonic-types/lib-auditlog
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Use
|
|
@@ -26,8 +26,8 @@ Add the corresponding types to your `tsconfig.json` file that is used for applic
|
|
|
26
26
|
|
|
27
27
|
### Require and custom imports
|
|
28
28
|
|
|
29
|
-
To make `require` work out of box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
30
|
-
objects, e.g. `log`, `app`, `__`, etc, requiring library by the default path will return typed object.
|
|
29
|
+
To make `require` work out of the box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
30
|
+
global objects, e.g. `log`, `app`, `__`, etc, requiring a library by the default path will return typed object.
|
|
31
31
|
|
|
32
32
|
`tsconfig.json`
|
|
33
33
|
|
|
@@ -49,7 +49,7 @@ const {log, get, find} = require('/lib/xp/auditlog');
|
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
More detailed explanation on how it works and how to type custom import function can be
|
|
52
|
-
found [here](https://
|
|
52
|
+
found [here](https://developer.enonic.com/docs/xp/stable/api).
|
|
53
53
|
|
|
54
54
|
### ES6-style import
|
|
55
55
|
|
package/auditlog.d.ts
CHANGED
|
@@ -1,92 +1,102 @@
|
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Functions to log and find audit logs.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* var auditLib = require('/lib/xp/auditlog');
|
|
6
|
+
*
|
|
7
|
+
* @module audit
|
|
8
|
+
*/
|
|
9
|
+
declare global {
|
|
10
|
+
interface XpLibraries {
|
|
11
|
+
'/lib/xp/auditlog': typeof import('./auditlog');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
import type { UserKey } from '@enonic-types/core';
|
|
15
|
+
export type { UserKey } from '@enonic-types/core';
|
|
16
|
+
export interface AuditLogParams {
|
|
17
|
+
type: string;
|
|
18
|
+
time?: string;
|
|
19
|
+
source?: string;
|
|
20
|
+
user?: UserKey;
|
|
21
|
+
objects?: string[];
|
|
22
|
+
data?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface AuditLog {
|
|
25
|
+
_id: string;
|
|
26
|
+
type: string;
|
|
27
|
+
time: string;
|
|
28
|
+
source: string;
|
|
29
|
+
user: UserKey;
|
|
30
|
+
objects: string[];
|
|
31
|
+
data: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* This function creates a single audit log entry.
|
|
35
|
+
*
|
|
36
|
+
* The parameter 'type' is required and all other parameters are optional.
|
|
37
|
+
*
|
|
38
|
+
* @example-ref examples/auditlog/log.js
|
|
39
|
+
*
|
|
40
|
+
* @param {object} params JSON with the parameters.
|
|
41
|
+
* @param {string} params.type Type of log entry.
|
|
42
|
+
* @param {string} [params.time] Log entry timestamp. Defaults to now.
|
|
43
|
+
* @param {string} [params.source] Log entry source. Defaults to the application ID.
|
|
44
|
+
* @param {string} [params.user] Log entry user. Defaults to the user of current context.
|
|
45
|
+
* @param {array} [params.objects] URIs to objects that relate to this log entry. Defaults to empty array.
|
|
46
|
+
* @param {object} [params.data] Custom extra data for the this log entry. Defaults to empty object.
|
|
47
|
+
*
|
|
48
|
+
* @returns {object} Audit log created as JSON.
|
|
49
|
+
*/
|
|
50
|
+
export declare function log(params: AuditLogParams): AuditLog;
|
|
51
|
+
export interface GetAuditLogParams {
|
|
52
|
+
id: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* This function fetches an audit log.
|
|
56
|
+
*
|
|
57
|
+
* @example-ref examples/auditlog/get.js
|
|
58
|
+
*
|
|
59
|
+
* @param {object} params JSON with the parameters.
|
|
60
|
+
* @param {string} params.id Id of the audit log.
|
|
61
|
+
*
|
|
62
|
+
* @returns {object} Audit log as JSON.
|
|
63
|
+
*/
|
|
64
|
+
export declare function get(params: GetAuditLogParams): AuditLog | null;
|
|
65
|
+
export interface FindAuditLogParams {
|
|
66
|
+
start?: number;
|
|
67
|
+
count?: number;
|
|
68
|
+
ids?: string[];
|
|
69
|
+
from?: string;
|
|
70
|
+
to?: string;
|
|
71
|
+
type?: string;
|
|
72
|
+
source?: string;
|
|
73
|
+
users?: string[];
|
|
74
|
+
objects?: string[];
|
|
75
|
+
}
|
|
76
|
+
export interface AuditLogs {
|
|
77
|
+
total: number;
|
|
78
|
+
count: number;
|
|
79
|
+
hits: AuditLog[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* This function searches for audit logs.
|
|
83
|
+
*
|
|
84
|
+
* All parameters are semi-optional, meaning that you should at least supply one
|
|
85
|
+
* of them. If no parameters are supplied you will get an empty result.
|
|
86
|
+
*
|
|
87
|
+
* @example-ref examples/auditlog/find.js
|
|
88
|
+
*
|
|
89
|
+
* @param {object} params JSON with the parameters.
|
|
90
|
+
* @param {number} [params.start=0] Start index (used for paging).
|
|
91
|
+
* @param {number} [params.count=10] Number of contents to fetch.
|
|
92
|
+
* @param {array} [params.ids] Filter by ids of audit logs.
|
|
93
|
+
* @param {string} [params.from] Filter by logs younger than from.
|
|
94
|
+
* @param {string} [params.to] Filter by logs older than to.
|
|
95
|
+
* @param {string} [params.type] Filter by type.
|
|
96
|
+
* @param {string} [params.source] Filter by source.
|
|
97
|
+
* @param {array} [params.users] Filter by user keys.
|
|
98
|
+
* @param {array} [params.objects] Filter by object URIs.
|
|
99
|
+
*
|
|
100
|
+
* @returns {object} Audit log search results.
|
|
101
|
+
*/
|
|
102
|
+
export declare function find(params: FindAuditLogParams): AuditLogs;
|
package/package.json
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@enonic-types/lib-auditlog",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Type definitions for lib-auditlog.",
|
|
5
|
-
"types": "auditlog.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"auditlog.d.ts"
|
|
8
|
-
],
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"enonic",
|
|
15
|
-
"enonic-xp",
|
|
16
|
-
"lib-auditlog",
|
|
17
|
-
"auditlog",
|
|
18
|
-
"types",
|
|
19
|
-
"typescript"
|
|
20
|
-
],
|
|
21
|
-
"contributors": [
|
|
22
|
-
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
-
],
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
}
|
|
32
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@enonic-types/lib-auditlog",
|
|
3
|
+
"version": "7.11.0-B3",
|
|
4
|
+
"description": "Type definitions for lib-auditlog.",
|
|
5
|
+
"types": "auditlog.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"auditlog.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"enonic",
|
|
15
|
+
"enonic-xp",
|
|
16
|
+
"lib-auditlog",
|
|
17
|
+
"auditlog",
|
|
18
|
+
"types",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"contributors": [
|
|
22
|
+
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
+
],
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@enonic-types/core": "7.11.0-B3"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
}
|
|
35
|
+
}
|