@objectstack/plugin-audit 4.0.4 → 4.0.5
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/index.d.mts +1 -2288
- package/dist/index.d.ts +1 -2288
- package/dist/index.js +6 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +32 -6
- package/.turbo/turbo-build.log +0 -22
- package/CHANGELOG.md +0 -73
- package/src/audit-plugin.ts +0 -47
- package/src/index.ts +0 -13
- package/src/objects/index.ts +0 -9
- package/src/objects/sys-audit-log.object.ts +0 -116
- package/tsconfig.json +0 -18
package/dist/index.js
CHANGED
|
@@ -20,108 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
AuditPlugin: () => AuditPlugin
|
|
24
|
-
SysAuditLog: () => SysAuditLog
|
|
23
|
+
AuditPlugin: () => AuditPlugin
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(index_exports);
|
|
27
26
|
|
|
28
|
-
// src/objects/sys-audit-log.object.ts
|
|
29
|
-
var import_data = require("@objectstack/spec/data");
|
|
30
|
-
var SysAuditLog = import_data.ObjectSchema.create({
|
|
31
|
-
namespace: "sys",
|
|
32
|
-
name: "audit_log",
|
|
33
|
-
label: "Audit Log",
|
|
34
|
-
pluralLabel: "Audit Logs",
|
|
35
|
-
icon: "scroll-text",
|
|
36
|
-
isSystem: true,
|
|
37
|
-
description: "Immutable audit trail for platform events",
|
|
38
|
-
titleFormat: "{action} on {object_name} by {user_id}",
|
|
39
|
-
compactLayout: ["action", "object_name", "user_id", "created_at"],
|
|
40
|
-
fields: {
|
|
41
|
-
id: import_data.Field.text({
|
|
42
|
-
label: "Audit Log ID",
|
|
43
|
-
required: true,
|
|
44
|
-
readonly: true
|
|
45
|
-
}),
|
|
46
|
-
created_at: import_data.Field.datetime({
|
|
47
|
-
label: "Timestamp",
|
|
48
|
-
required: true,
|
|
49
|
-
defaultValue: "NOW()",
|
|
50
|
-
readonly: true
|
|
51
|
-
}),
|
|
52
|
-
user_id: import_data.Field.text({
|
|
53
|
-
label: "User ID",
|
|
54
|
-
required: false,
|
|
55
|
-
description: "User who performed the action (null for system actions)"
|
|
56
|
-
}),
|
|
57
|
-
action: import_data.Field.select(["create", "update", "delete", "restore", "login", "logout", "permission_change", "config_change", "export", "import"], {
|
|
58
|
-
label: "Action",
|
|
59
|
-
required: true,
|
|
60
|
-
description: "Action type (snake_case). Values: create, update, delete, restore, login, logout, permission_change, config_change, export, import"
|
|
61
|
-
}),
|
|
62
|
-
object_name: import_data.Field.text({
|
|
63
|
-
label: "Object Name",
|
|
64
|
-
required: false,
|
|
65
|
-
maxLength: 255,
|
|
66
|
-
description: "Target object (e.g. sys_user, project_task)"
|
|
67
|
-
}),
|
|
68
|
-
record_id: import_data.Field.text({
|
|
69
|
-
label: "Record ID",
|
|
70
|
-
required: false,
|
|
71
|
-
description: "ID of the affected record"
|
|
72
|
-
}),
|
|
73
|
-
old_value: import_data.Field.textarea({
|
|
74
|
-
label: "Old Value",
|
|
75
|
-
required: false,
|
|
76
|
-
description: "JSON-serialized previous state"
|
|
77
|
-
}),
|
|
78
|
-
new_value: import_data.Field.textarea({
|
|
79
|
-
label: "New Value",
|
|
80
|
-
required: false,
|
|
81
|
-
description: "JSON-serialized new state"
|
|
82
|
-
}),
|
|
83
|
-
ip_address: import_data.Field.text({
|
|
84
|
-
label: "IP Address",
|
|
85
|
-
required: false,
|
|
86
|
-
maxLength: 45
|
|
87
|
-
}),
|
|
88
|
-
user_agent: import_data.Field.textarea({
|
|
89
|
-
label: "User Agent",
|
|
90
|
-
required: false
|
|
91
|
-
}),
|
|
92
|
-
tenant_id: import_data.Field.text({
|
|
93
|
-
label: "Tenant ID",
|
|
94
|
-
required: false,
|
|
95
|
-
description: "Tenant context for multi-tenant isolation"
|
|
96
|
-
}),
|
|
97
|
-
metadata: import_data.Field.textarea({
|
|
98
|
-
label: "Metadata",
|
|
99
|
-
required: false,
|
|
100
|
-
description: "JSON-serialized additional context"
|
|
101
|
-
})
|
|
102
|
-
},
|
|
103
|
-
indexes: [
|
|
104
|
-
{ fields: ["created_at"] },
|
|
105
|
-
{ fields: ["user_id"] },
|
|
106
|
-
{ fields: ["object_name", "record_id"] },
|
|
107
|
-
{ fields: ["action"] },
|
|
108
|
-
{ fields: ["tenant_id"] }
|
|
109
|
-
],
|
|
110
|
-
enable: {
|
|
111
|
-
trackHistory: false,
|
|
112
|
-
// Audit logs are themselves the audit trail
|
|
113
|
-
searchable: true,
|
|
114
|
-
apiEnabled: true,
|
|
115
|
-
apiMethods: ["get", "list"],
|
|
116
|
-
// Read-only — audit logs are immutable; creation happens via internal system hooks only
|
|
117
|
-
trash: false,
|
|
118
|
-
// Never soft-delete audit logs
|
|
119
|
-
mru: false,
|
|
120
|
-
clone: false
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
27
|
// src/audit-plugin.ts
|
|
28
|
+
var import_audit = require("@objectstack/platform-objects/audit");
|
|
125
29
|
var AuditPlugin = class {
|
|
126
30
|
constructor() {
|
|
127
31
|
this.name = "com.objectstack.audit";
|
|
@@ -135,28 +39,16 @@ var AuditPlugin = class {
|
|
|
135
39
|
name: "Audit",
|
|
136
40
|
version: "1.0.0",
|
|
137
41
|
type: "plugin",
|
|
42
|
+
scope: "system",
|
|
43
|
+
defaultDatasource: "cloud",
|
|
138
44
|
namespace: "sys",
|
|
139
|
-
objects: [SysAuditLog]
|
|
45
|
+
objects: [import_audit.SysAuditLog, import_audit.SysActivity, import_audit.SysComment]
|
|
140
46
|
});
|
|
141
|
-
try {
|
|
142
|
-
const setupNav = ctx.getService("setupNav");
|
|
143
|
-
if (setupNav) {
|
|
144
|
-
setupNav.contribute({
|
|
145
|
-
areaId: "area_system",
|
|
146
|
-
items: [
|
|
147
|
-
{ id: "nav_audit_logs", type: "object", label: "Audit Logs", objectName: "audit_log", icon: "scroll-text", order: 10 }
|
|
148
|
-
]
|
|
149
|
-
});
|
|
150
|
-
ctx.logger.info("Audit navigation items contributed to Setup App");
|
|
151
|
-
}
|
|
152
|
-
} catch {
|
|
153
|
-
}
|
|
154
47
|
ctx.logger.info("Audit Plugin initialized");
|
|
155
48
|
}
|
|
156
49
|
};
|
|
157
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
158
51
|
0 && (module.exports = {
|
|
159
|
-
AuditPlugin
|
|
160
|
-
SysAuditLog
|
|
52
|
+
AuditPlugin
|
|
161
53
|
});
|
|
162
54
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/audit-plugin.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * @objectstack/plugin-audit\n *\n * Audit Plugin for ObjectStack\n * Provides the sys_audit_log system object definition for immutable audit trails.\n */\n\nexport { AuditPlugin } from './audit-plugin.js';\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { SysAuditLog, SysActivity, SysComment } from '@objectstack/platform-objects/audit';\n\n/**\n * AuditPlugin\n *\n * Registers the sys_audit_log system object with ObjectQL so it is\n * discoverable by the studio and available for CRUD operations.\n */\nexport class AuditPlugin implements Plugin {\n name = 'com.objectstack.audit';\n type = 'standard';\n version = '1.0.0';\n dependencies = ['com.objectstack.engine.objectql'];\n\n async init(ctx: PluginContext): Promise<void> {\n // Register audit system objects via the manifest service.\n ctx.getService<{ register(m: any): void }>('manifest').register({\n id: 'com.objectstack.audit',\n name: 'Audit',\n version: '1.0.0',\n type: 'plugin',\n scope: 'system',\n defaultDatasource: 'cloud',\n namespace: 'sys',\n objects: [SysAuditLog, SysActivity, SysComment],\n });\n\n ctx.logger.info('Audit Plugin initialized');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,mBAAqD;AAQ9C,IAAM,cAAN,MAAoC;AAAA,EAApC;AACL,gBAAO;AACP,gBAAO;AACP,mBAAU;AACV,wBAAe,CAAC,iCAAiC;AAAA;AAAA,EAEjD,MAAM,KAAK,KAAmC;AAE5C,QAAI,WAAuC,UAAU,EAAE,SAAS;AAAA,MAC9D,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM;AAAA,MACN,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,WAAW;AAAA,MACX,SAAS,CAAC,0BAAa,0BAAa,uBAAU;AAAA,IAChD,CAAC;AAED,QAAI,OAAO,KAAK,0BAA0B;AAAA,EAC5C;AACF;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,100 +1,5 @@
|
|
|
1
|
-
// src/objects/sys-audit-log.object.ts
|
|
2
|
-
import { ObjectSchema, Field } from "@objectstack/spec/data";
|
|
3
|
-
var SysAuditLog = ObjectSchema.create({
|
|
4
|
-
namespace: "sys",
|
|
5
|
-
name: "audit_log",
|
|
6
|
-
label: "Audit Log",
|
|
7
|
-
pluralLabel: "Audit Logs",
|
|
8
|
-
icon: "scroll-text",
|
|
9
|
-
isSystem: true,
|
|
10
|
-
description: "Immutable audit trail for platform events",
|
|
11
|
-
titleFormat: "{action} on {object_name} by {user_id}",
|
|
12
|
-
compactLayout: ["action", "object_name", "user_id", "created_at"],
|
|
13
|
-
fields: {
|
|
14
|
-
id: Field.text({
|
|
15
|
-
label: "Audit Log ID",
|
|
16
|
-
required: true,
|
|
17
|
-
readonly: true
|
|
18
|
-
}),
|
|
19
|
-
created_at: Field.datetime({
|
|
20
|
-
label: "Timestamp",
|
|
21
|
-
required: true,
|
|
22
|
-
defaultValue: "NOW()",
|
|
23
|
-
readonly: true
|
|
24
|
-
}),
|
|
25
|
-
user_id: Field.text({
|
|
26
|
-
label: "User ID",
|
|
27
|
-
required: false,
|
|
28
|
-
description: "User who performed the action (null for system actions)"
|
|
29
|
-
}),
|
|
30
|
-
action: Field.select(["create", "update", "delete", "restore", "login", "logout", "permission_change", "config_change", "export", "import"], {
|
|
31
|
-
label: "Action",
|
|
32
|
-
required: true,
|
|
33
|
-
description: "Action type (snake_case). Values: create, update, delete, restore, login, logout, permission_change, config_change, export, import"
|
|
34
|
-
}),
|
|
35
|
-
object_name: Field.text({
|
|
36
|
-
label: "Object Name",
|
|
37
|
-
required: false,
|
|
38
|
-
maxLength: 255,
|
|
39
|
-
description: "Target object (e.g. sys_user, project_task)"
|
|
40
|
-
}),
|
|
41
|
-
record_id: Field.text({
|
|
42
|
-
label: "Record ID",
|
|
43
|
-
required: false,
|
|
44
|
-
description: "ID of the affected record"
|
|
45
|
-
}),
|
|
46
|
-
old_value: Field.textarea({
|
|
47
|
-
label: "Old Value",
|
|
48
|
-
required: false,
|
|
49
|
-
description: "JSON-serialized previous state"
|
|
50
|
-
}),
|
|
51
|
-
new_value: Field.textarea({
|
|
52
|
-
label: "New Value",
|
|
53
|
-
required: false,
|
|
54
|
-
description: "JSON-serialized new state"
|
|
55
|
-
}),
|
|
56
|
-
ip_address: Field.text({
|
|
57
|
-
label: "IP Address",
|
|
58
|
-
required: false,
|
|
59
|
-
maxLength: 45
|
|
60
|
-
}),
|
|
61
|
-
user_agent: Field.textarea({
|
|
62
|
-
label: "User Agent",
|
|
63
|
-
required: false
|
|
64
|
-
}),
|
|
65
|
-
tenant_id: Field.text({
|
|
66
|
-
label: "Tenant ID",
|
|
67
|
-
required: false,
|
|
68
|
-
description: "Tenant context for multi-tenant isolation"
|
|
69
|
-
}),
|
|
70
|
-
metadata: Field.textarea({
|
|
71
|
-
label: "Metadata",
|
|
72
|
-
required: false,
|
|
73
|
-
description: "JSON-serialized additional context"
|
|
74
|
-
})
|
|
75
|
-
},
|
|
76
|
-
indexes: [
|
|
77
|
-
{ fields: ["created_at"] },
|
|
78
|
-
{ fields: ["user_id"] },
|
|
79
|
-
{ fields: ["object_name", "record_id"] },
|
|
80
|
-
{ fields: ["action"] },
|
|
81
|
-
{ fields: ["tenant_id"] }
|
|
82
|
-
],
|
|
83
|
-
enable: {
|
|
84
|
-
trackHistory: false,
|
|
85
|
-
// Audit logs are themselves the audit trail
|
|
86
|
-
searchable: true,
|
|
87
|
-
apiEnabled: true,
|
|
88
|
-
apiMethods: ["get", "list"],
|
|
89
|
-
// Read-only — audit logs are immutable; creation happens via internal system hooks only
|
|
90
|
-
trash: false,
|
|
91
|
-
// Never soft-delete audit logs
|
|
92
|
-
mru: false,
|
|
93
|
-
clone: false
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
1
|
// src/audit-plugin.ts
|
|
2
|
+
import { SysAuditLog, SysActivity, SysComment } from "@objectstack/platform-objects/audit";
|
|
98
3
|
var AuditPlugin = class {
|
|
99
4
|
constructor() {
|
|
100
5
|
this.name = "com.objectstack.audit";
|
|
@@ -108,27 +13,15 @@ var AuditPlugin = class {
|
|
|
108
13
|
name: "Audit",
|
|
109
14
|
version: "1.0.0",
|
|
110
15
|
type: "plugin",
|
|
16
|
+
scope: "system",
|
|
17
|
+
defaultDatasource: "cloud",
|
|
111
18
|
namespace: "sys",
|
|
112
|
-
objects: [SysAuditLog]
|
|
19
|
+
objects: [SysAuditLog, SysActivity, SysComment]
|
|
113
20
|
});
|
|
114
|
-
try {
|
|
115
|
-
const setupNav = ctx.getService("setupNav");
|
|
116
|
-
if (setupNav) {
|
|
117
|
-
setupNav.contribute({
|
|
118
|
-
areaId: "area_system",
|
|
119
|
-
items: [
|
|
120
|
-
{ id: "nav_audit_logs", type: "object", label: "Audit Logs", objectName: "audit_log", icon: "scroll-text", order: 10 }
|
|
121
|
-
]
|
|
122
|
-
});
|
|
123
|
-
ctx.logger.info("Audit navigation items contributed to Setup App");
|
|
124
|
-
}
|
|
125
|
-
} catch {
|
|
126
|
-
}
|
|
127
21
|
ctx.logger.info("Audit Plugin initialized");
|
|
128
22
|
}
|
|
129
23
|
};
|
|
130
24
|
export {
|
|
131
|
-
AuditPlugin
|
|
132
|
-
SysAuditLog
|
|
25
|
+
AuditPlugin
|
|
133
26
|
};
|
|
134
27
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/audit-plugin.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { SysAuditLog, SysActivity, SysComment } from '@objectstack/platform-objects/audit';\n\n/**\n * AuditPlugin\n *\n * Registers the sys_audit_log system object with ObjectQL so it is\n * discoverable by the studio and available for CRUD operations.\n */\nexport class AuditPlugin implements Plugin {\n name = 'com.objectstack.audit';\n type = 'standard';\n version = '1.0.0';\n dependencies = ['com.objectstack.engine.objectql'];\n\n async init(ctx: PluginContext): Promise<void> {\n // Register audit system objects via the manifest service.\n ctx.getService<{ register(m: any): void }>('manifest').register({\n id: 'com.objectstack.audit',\n name: 'Audit',\n version: '1.0.0',\n type: 'plugin',\n scope: 'system',\n defaultDatasource: 'cloud',\n namespace: 'sys',\n objects: [SysAuditLog, SysActivity, SysComment],\n });\n\n ctx.logger.info('Audit Plugin initialized');\n }\n}\n"],"mappings":";AAGA,SAAS,aAAa,aAAa,kBAAkB;AAQ9C,IAAM,cAAN,MAAoC;AAAA,EAApC;AACL,gBAAO;AACP,gBAAO;AACP,mBAAU;AACV,wBAAe,CAAC,iCAAiC;AAAA;AAAA,EAEjD,MAAM,KAAK,KAAmC;AAE5C,QAAI,WAAuC,UAAU,EAAE,SAAS;AAAA,MAC9D,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM;AAAA,MACN,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,WAAW;AAAA,MACX,SAAS,CAAC,aAAa,aAAa,UAAU;AAAA,IAChD,CAAC;AAED,QAAI,OAAO,KAAK,0BAA0B;AAAA,EAC5C;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/plugin-audit",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Audit Plugin for ObjectStack — System audit log object and audit trail",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,13 +13,39 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@objectstack/core": "4.0.
|
|
17
|
-
"@objectstack/
|
|
16
|
+
"@objectstack/core": "4.0.5",
|
|
17
|
+
"@objectstack/platform-objects": "4.0.5",
|
|
18
|
+
"@objectstack/spec": "4.0.5"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
|
-
"@types/node": "^25.6.
|
|
21
|
-
"typescript": "^6.0.
|
|
22
|
-
"vitest": "^4.1.
|
|
21
|
+
"@types/node": "^25.6.2",
|
|
22
|
+
"typescript": "^6.0.3",
|
|
23
|
+
"vitest": "^4.1.5"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"objectstack",
|
|
27
|
+
"plugin",
|
|
28
|
+
"audit",
|
|
29
|
+
"logging",
|
|
30
|
+
"compliance"
|
|
31
|
+
],
|
|
32
|
+
"author": "ObjectStack",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/objectstack-ai/framework.git",
|
|
36
|
+
"directory": "packages/plugins/plugin-audit"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://objectstack.ai/docs",
|
|
39
|
+
"bugs": "https://github.com/objectstack-ai/framework/issues",
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"README.md"
|
|
46
|
+
],
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.0.0"
|
|
23
49
|
},
|
|
24
50
|
"scripts": {
|
|
25
51
|
"build": "tsup --config ../../../tsup.config.ts",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @objectstack/plugin-audit@4.0.4 build /home/runner/work/framework/framework/packages/plugins/plugin-audit
|
|
3
|
-
> tsup --config ../../../tsup.config.ts
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.5.1
|
|
8
|
-
[34mCLI[39m Using tsup config: /home/runner/work/framework/framework/tsup.config.ts
|
|
9
|
-
[34mCLI[39m Target: es2020
|
|
10
|
-
[34mCLI[39m Cleaning output folder
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[34mCJS[39m Build start
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[32m4.93 KB[39m
|
|
14
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m7.55 KB[39m
|
|
15
|
-
[32mCJS[39m ⚡️ Build success in 79ms
|
|
16
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m3.75 KB[39m
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m7.10 KB[39m
|
|
18
|
-
[32mESM[39m ⚡️ Build success in 82ms
|
|
19
|
-
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in 21495ms
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m103.78 KB[39m
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m103.78 KB[39m
|
package/CHANGELOG.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# @objectstack/plugin-audit
|
|
2
|
-
|
|
3
|
-
## 4.0.4
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [326b66b]
|
|
8
|
-
- @objectstack/spec@4.0.4
|
|
9
|
-
- @objectstack/core@4.0.4
|
|
10
|
-
|
|
11
|
-
## 4.0.3
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- @objectstack/spec@4.0.3
|
|
16
|
-
- @objectstack/core@4.0.3
|
|
17
|
-
|
|
18
|
-
## 4.0.2
|
|
19
|
-
|
|
20
|
-
### Patch Changes
|
|
21
|
-
|
|
22
|
-
- Updated dependencies [5f659e9]
|
|
23
|
-
- @objectstack/spec@4.0.2
|
|
24
|
-
- @objectstack/core@4.0.2
|
|
25
|
-
|
|
26
|
-
## 4.0.0
|
|
27
|
-
|
|
28
|
-
### Patch Changes
|
|
29
|
-
|
|
30
|
-
- Updated dependencies [f08ffc3]
|
|
31
|
-
- Updated dependencies [e0b0a78]
|
|
32
|
-
- @objectstack/spec@4.0.0
|
|
33
|
-
- @objectstack/core@4.0.0
|
|
34
|
-
|
|
35
|
-
## 3.3.1
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- @objectstack/spec@3.3.1
|
|
40
|
-
- @objectstack/core@3.3.1
|
|
41
|
-
|
|
42
|
-
## 3.2.10
|
|
43
|
-
|
|
44
|
-
### Patch Changes
|
|
45
|
-
|
|
46
|
-
- @objectstack/spec@3.3.0
|
|
47
|
-
- @objectstack/core@3.3.0
|
|
48
|
-
|
|
49
|
-
## 3.2.9
|
|
50
|
-
|
|
51
|
-
### Patch Changes
|
|
52
|
-
|
|
53
|
-
- @objectstack/spec@3.2.9
|
|
54
|
-
- @objectstack/core@3.2.9
|
|
55
|
-
|
|
56
|
-
## 3.2.8
|
|
57
|
-
|
|
58
|
-
### Patch Changes
|
|
59
|
-
|
|
60
|
-
- @objectstack/spec@3.2.8
|
|
61
|
-
- @objectstack/core@3.2.8
|
|
62
|
-
|
|
63
|
-
## 3.2.7
|
|
64
|
-
|
|
65
|
-
### Patch Changes
|
|
66
|
-
|
|
67
|
-
- @objectstack/spec@3.2.7
|
|
68
|
-
|
|
69
|
-
## 3.2.6
|
|
70
|
-
|
|
71
|
-
### Patch Changes
|
|
72
|
-
|
|
73
|
-
- @objectstack/spec@3.2.6
|
package/src/audit-plugin.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import type { Plugin, PluginContext } from '@objectstack/core';
|
|
4
|
-
import { SysAuditLog } from './objects/index.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* AuditPlugin
|
|
8
|
-
*
|
|
9
|
-
* Registers the sys_audit_log system object with ObjectQL so it is
|
|
10
|
-
* discoverable by the studio and available for CRUD operations.
|
|
11
|
-
*/
|
|
12
|
-
export class AuditPlugin implements Plugin {
|
|
13
|
-
name = 'com.objectstack.audit';
|
|
14
|
-
type = 'standard';
|
|
15
|
-
version = '1.0.0';
|
|
16
|
-
dependencies = ['com.objectstack.engine.objectql'];
|
|
17
|
-
|
|
18
|
-
async init(ctx: PluginContext): Promise<void> {
|
|
19
|
-
// Register audit system objects via the manifest service.
|
|
20
|
-
ctx.getService<{ register(m: any): void }>('manifest').register({
|
|
21
|
-
id: 'com.objectstack.audit',
|
|
22
|
-
name: 'Audit',
|
|
23
|
-
version: '1.0.0',
|
|
24
|
-
type: 'plugin',
|
|
25
|
-
namespace: 'sys',
|
|
26
|
-
objects: [SysAuditLog],
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Contribute navigation items to the Setup App (if SetupPlugin is loaded).
|
|
30
|
-
try {
|
|
31
|
-
const setupNav = ctx.getService<{ contribute(c: any): void }>('setupNav');
|
|
32
|
-
if (setupNav) {
|
|
33
|
-
setupNav.contribute({
|
|
34
|
-
areaId: 'area_system',
|
|
35
|
-
items: [
|
|
36
|
-
{ id: 'nav_audit_logs', type: 'object', label: 'Audit Logs', objectName: 'audit_log', icon: 'scroll-text', order: 10 },
|
|
37
|
-
],
|
|
38
|
-
});
|
|
39
|
-
ctx.logger.info('Audit navigation items contributed to Setup App');
|
|
40
|
-
}
|
|
41
|
-
} catch {
|
|
42
|
-
// SetupPlugin not loaded — skip silently
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
ctx.logger.info('Audit Plugin initialized');
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @objectstack/plugin-audit
|
|
5
|
-
*
|
|
6
|
-
* Audit Plugin for ObjectStack
|
|
7
|
-
* Provides the sys_audit_log system object definition for immutable audit trails.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export { AuditPlugin } from './audit-plugin.js';
|
|
11
|
-
|
|
12
|
-
// System Object Definitions (sys namespace)
|
|
13
|
-
export { SysAuditLog } from './objects/index.js';
|
package/src/objects/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Audit Plugin — System Object Definitions (sys namespace)
|
|
5
|
-
*
|
|
6
|
-
* Canonical ObjectSchema definitions for audit-related system objects.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export { SysAuditLog } from './sys-audit-log.object.js';
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import { ObjectSchema, Field } from '@objectstack/spec/data';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* sys_audit_log — System Audit Log Object
|
|
7
|
-
*
|
|
8
|
-
* Immutable audit trail for all significant platform events.
|
|
9
|
-
* Records who did what, when, and the before/after state.
|
|
10
|
-
*
|
|
11
|
-
* @namespace sys
|
|
12
|
-
*/
|
|
13
|
-
export const SysAuditLog = ObjectSchema.create({
|
|
14
|
-
namespace: 'sys',
|
|
15
|
-
name: 'audit_log',
|
|
16
|
-
label: 'Audit Log',
|
|
17
|
-
pluralLabel: 'Audit Logs',
|
|
18
|
-
icon: 'scroll-text',
|
|
19
|
-
isSystem: true,
|
|
20
|
-
description: 'Immutable audit trail for platform events',
|
|
21
|
-
titleFormat: '{action} on {object_name} by {user_id}',
|
|
22
|
-
compactLayout: ['action', 'object_name', 'user_id', 'created_at'],
|
|
23
|
-
|
|
24
|
-
fields: {
|
|
25
|
-
id: Field.text({
|
|
26
|
-
label: 'Audit Log ID',
|
|
27
|
-
required: true,
|
|
28
|
-
readonly: true,
|
|
29
|
-
}),
|
|
30
|
-
|
|
31
|
-
created_at: Field.datetime({
|
|
32
|
-
label: 'Timestamp',
|
|
33
|
-
required: true,
|
|
34
|
-
defaultValue: 'NOW()',
|
|
35
|
-
readonly: true,
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
user_id: Field.text({
|
|
39
|
-
label: 'User ID',
|
|
40
|
-
required: false,
|
|
41
|
-
description: 'User who performed the action (null for system actions)',
|
|
42
|
-
}),
|
|
43
|
-
|
|
44
|
-
action: Field.select(['create', 'update', 'delete', 'restore', 'login', 'logout', 'permission_change', 'config_change', 'export', 'import'], {
|
|
45
|
-
label: 'Action',
|
|
46
|
-
required: true,
|
|
47
|
-
description: 'Action type (snake_case). Values: create, update, delete, restore, login, logout, permission_change, config_change, export, import',
|
|
48
|
-
}),
|
|
49
|
-
|
|
50
|
-
object_name: Field.text({
|
|
51
|
-
label: 'Object Name',
|
|
52
|
-
required: false,
|
|
53
|
-
maxLength: 255,
|
|
54
|
-
description: 'Target object (e.g. sys_user, project_task)',
|
|
55
|
-
}),
|
|
56
|
-
|
|
57
|
-
record_id: Field.text({
|
|
58
|
-
label: 'Record ID',
|
|
59
|
-
required: false,
|
|
60
|
-
description: 'ID of the affected record',
|
|
61
|
-
}),
|
|
62
|
-
|
|
63
|
-
old_value: Field.textarea({
|
|
64
|
-
label: 'Old Value',
|
|
65
|
-
required: false,
|
|
66
|
-
description: 'JSON-serialized previous state',
|
|
67
|
-
}),
|
|
68
|
-
|
|
69
|
-
new_value: Field.textarea({
|
|
70
|
-
label: 'New Value',
|
|
71
|
-
required: false,
|
|
72
|
-
description: 'JSON-serialized new state',
|
|
73
|
-
}),
|
|
74
|
-
|
|
75
|
-
ip_address: Field.text({
|
|
76
|
-
label: 'IP Address',
|
|
77
|
-
required: false,
|
|
78
|
-
maxLength: 45,
|
|
79
|
-
}),
|
|
80
|
-
|
|
81
|
-
user_agent: Field.textarea({
|
|
82
|
-
label: 'User Agent',
|
|
83
|
-
required: false,
|
|
84
|
-
}),
|
|
85
|
-
|
|
86
|
-
tenant_id: Field.text({
|
|
87
|
-
label: 'Tenant ID',
|
|
88
|
-
required: false,
|
|
89
|
-
description: 'Tenant context for multi-tenant isolation',
|
|
90
|
-
}),
|
|
91
|
-
|
|
92
|
-
metadata: Field.textarea({
|
|
93
|
-
label: 'Metadata',
|
|
94
|
-
required: false,
|
|
95
|
-
description: 'JSON-serialized additional context',
|
|
96
|
-
}),
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
indexes: [
|
|
100
|
-
{ fields: ['created_at'] },
|
|
101
|
-
{ fields: ['user_id'] },
|
|
102
|
-
{ fields: ['object_name', 'record_id'] },
|
|
103
|
-
{ fields: ['action'] },
|
|
104
|
-
{ fields: ['tenant_id'] },
|
|
105
|
-
],
|
|
106
|
-
|
|
107
|
-
enable: {
|
|
108
|
-
trackHistory: false, // Audit logs are themselves the audit trail
|
|
109
|
-
searchable: true,
|
|
110
|
-
apiEnabled: true,
|
|
111
|
-
apiMethods: ['get', 'list'], // Read-only — audit logs are immutable; creation happens via internal system hooks only
|
|
112
|
-
trash: false, // Never soft-delete audit logs
|
|
113
|
-
mru: false,
|
|
114
|
-
clone: false,
|
|
115
|
-
},
|
|
116
|
-
});
|