@objectstack/plugin-audit 4.0.3 → 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.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/objects/sys-audit-log.object.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\n// System Object Definitions (sys namespace)\nexport { SysAuditLog } from './objects/index.js';\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { ObjectSchema, Field } from '@objectstack/spec/data';\n\n/**\n * sys_audit_log — System Audit Log Object\n *\n * Immutable audit trail for all significant platform events.\n * Records who did what, when, and the before/after state.\n *\n * @namespace sys\n */\nexport const SysAuditLog = ObjectSchema.create({\n namespace: 'sys',\n name: 'audit_log',\n label: 'Audit Log',\n pluralLabel: 'Audit Logs',\n icon: 'scroll-text',\n isSystem: true,\n description: 'Immutable audit trail for platform events',\n titleFormat: '{action} on {object_name} by {user_id}',\n compactLayout: ['action', 'object_name', 'user_id', 'created_at'],\n \n fields: {\n id: Field.text({\n label: 'Audit Log ID',\n required: true,\n readonly: true,\n }),\n \n created_at: Field.datetime({\n label: 'Timestamp',\n required: true,\n defaultValue: 'NOW()',\n readonly: true,\n }),\n \n user_id: Field.text({\n label: 'User ID',\n required: false,\n description: 'User who performed the action (null for system actions)',\n }),\n \n action: Field.select(['create', 'update', 'delete', 'restore', 'login', 'logout', 'permission_change', 'config_change', 'export', 'import'], {\n label: 'Action',\n required: true,\n description: 'Action type (snake_case). Values: create, update, delete, restore, login, logout, permission_change, config_change, export, import',\n }),\n \n object_name: Field.text({\n label: 'Object Name',\n required: false,\n maxLength: 255,\n description: 'Target object (e.g. sys_user, project_task)',\n }),\n \n record_id: Field.text({\n label: 'Record ID',\n required: false,\n description: 'ID of the affected record',\n }),\n \n old_value: Field.textarea({\n label: 'Old Value',\n required: false,\n description: 'JSON-serialized previous state',\n }),\n \n new_value: Field.textarea({\n label: 'New Value',\n required: false,\n description: 'JSON-serialized new state',\n }),\n \n ip_address: Field.text({\n label: 'IP Address',\n required: false,\n maxLength: 45,\n }),\n \n user_agent: Field.textarea({\n label: 'User Agent',\n required: false,\n }),\n \n tenant_id: Field.text({\n label: 'Tenant ID',\n required: false,\n description: 'Tenant context for multi-tenant isolation',\n }),\n \n metadata: Field.textarea({\n label: 'Metadata',\n required: false,\n description: 'JSON-serialized additional context',\n }),\n },\n \n indexes: [\n { fields: ['created_at'] },\n { fields: ['user_id'] },\n { fields: ['object_name', 'record_id'] },\n { fields: ['action'] },\n { fields: ['tenant_id'] },\n ],\n \n enable: {\n trackHistory: false, // Audit logs are themselves the audit trail\n searchable: true,\n apiEnabled: true,\n apiMethods: ['get', 'list'], // Read-only — audit logs are immutable; creation happens via internal system hooks only\n trash: false, // Never soft-delete audit logs\n mru: false,\n clone: false,\n },\n});\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { SysAuditLog } from './objects/index.js';\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 namespace: 'sys',\n objects: [SysAuditLog],\n });\n\n // Contribute navigation items to the Setup App (if SetupPlugin is loaded).\n try {\n const setupNav = ctx.getService<{ contribute(c: any): void }>('setupNav');\n if (setupNav) {\n setupNav.contribute({\n areaId: 'area_system',\n items: [\n { id: 'nav_audit_logs', type: 'object', label: 'Audit Logs', objectName: 'audit_log', icon: 'scroll-text', order: 10 },\n ],\n });\n ctx.logger.info('Audit navigation items contributed to Setup App');\n }\n } catch {\n // SetupPlugin not loaded — skip silently\n }\n\n ctx.logger.info('Audit Plugin initialized');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,kBAAoC;AAU7B,IAAM,cAAc,yBAAa,OAAO;AAAA,EAC7C,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,EACb,aAAa;AAAA,EACb,eAAe,CAAC,UAAU,eAAe,WAAW,YAAY;AAAA,EAEhE,QAAQ;AAAA,IACN,IAAI,kBAAM,KAAK;AAAA,MACb,OAAO;AAAA,MACP,UAAU;AAAA,MACV,UAAU;AAAA,IACZ,CAAC;AAAA,IAED,YAAY,kBAAM,SAAS;AAAA,MACzB,OAAO;AAAA,MACP,UAAU;AAAA,MACV,cAAc;AAAA,MACd,UAAU;AAAA,IACZ,CAAC;AAAA,IAED,SAAS,kBAAM,KAAK;AAAA,MAClB,OAAO;AAAA,MACP,UAAU;AAAA,MACV,aAAa;AAAA,IACf,CAAC;AAAA,IAED,QAAQ,kBAAM,OAAO,CAAC,UAAU,UAAU,UAAU,WAAW,SAAS,UAAU,qBAAqB,iBAAiB,UAAU,QAAQ,GAAG;AAAA,MAC3I,OAAO;AAAA,MACP,UAAU;AAAA,MACV,aAAa;AAAA,IACf,CAAC;AAAA,IAED,aAAa,kBAAM,KAAK;AAAA,MACtB,OAAO;AAAA,M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A,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,WAAW;AAAA,MACX,SAAS,CAAC,WAAW;AAAA,IACvB,CAAC;AAGD,QAAI;AACF,YAAM,WAAW,IAAI,WAAyC,UAAU;AACxE,UAAI,UAAU;AACZ,iBAAS,WAAW;AAAA,UAClB,QAAQ;AAAA,UACR,OAAO;AAAA,YACL,EAAE,IAAI,kBAAkB,MAAM,UAAU,OAAO,cAAc,YAAY,aAAa,MAAM,eAAe,OAAO,GAAG;AAAA,UACvH;AAAA,QACF,CAAC;AACD,YAAI,OAAO,KAAK,iDAAiD;AAAA,MACnE;AAAA,IACF,QAAQ;AAAA,IAER;AAEA,QAAI,OAAO,KAAK,0BAA0B;AAAA,EAC5C;AACF;","names":[]}
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
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/objects/sys-audit-log.object.ts","../src/audit-plugin.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { ObjectSchema, Field } from '@objectstack/spec/data';\n\n/**\n * sys_audit_log — System Audit Log Object\n *\n * Immutable audit trail for all significant platform events.\n * Records who did what, when, and the before/after state.\n *\n * @namespace sys\n */\nexport const SysAuditLog = ObjectSchema.create({\n namespace: 'sys',\n name: 'audit_log',\n label: 'Audit Log',\n pluralLabel: 'Audit Logs',\n icon: 'scroll-text',\n isSystem: true,\n description: 'Immutable audit trail for platform events',\n titleFormat: '{action} on {object_name} by {user_id}',\n compactLayout: ['action', 'object_name', 'user_id', 'created_at'],\n \n fields: {\n id: Field.text({\n label: 'Audit Log ID',\n required: true,\n readonly: true,\n }),\n \n created_at: Field.datetime({\n label: 'Timestamp',\n required: true,\n defaultValue: 'NOW()',\n readonly: true,\n }),\n \n user_id: Field.text({\n label: 'User ID',\n required: false,\n description: 'User who performed the action (null for system actions)',\n }),\n \n action: Field.select(['create', 'update', 'delete', 'restore', 'login', 'logout', 'permission_change', 'config_change', 'export', 'import'], {\n label: 'Action',\n required: true,\n description: 'Action type (snake_case). Values: create, update, delete, restore, login, logout, permission_change, config_change, export, import',\n }),\n \n object_name: Field.text({\n label: 'Object Name',\n required: false,\n maxLength: 255,\n description: 'Target object (e.g. sys_user, project_task)',\n }),\n \n record_id: Field.text({\n label: 'Record ID',\n required: false,\n description: 'ID of the affected record',\n }),\n \n old_value: Field.textarea({\n label: 'Old Value',\n required: false,\n description: 'JSON-serialized previous state',\n }),\n \n new_value: Field.textarea({\n label: 'New Value',\n required: false,\n description: 'JSON-serialized new state',\n }),\n \n ip_address: Field.text({\n label: 'IP Address',\n required: false,\n maxLength: 45,\n }),\n \n user_agent: Field.textarea({\n label: 'User Agent',\n required: false,\n }),\n \n tenant_id: Field.text({\n label: 'Tenant ID',\n required: false,\n description: 'Tenant context for multi-tenant isolation',\n }),\n \n metadata: Field.textarea({\n label: 'Metadata',\n required: false,\n description: 'JSON-serialized additional context',\n }),\n },\n \n indexes: [\n { fields: ['created_at'] },\n { fields: ['user_id'] },\n { fields: ['object_name', 'record_id'] },\n { fields: ['action'] },\n { fields: ['tenant_id'] },\n ],\n \n enable: {\n trackHistory: false, // Audit logs are themselves the audit trail\n searchable: true,\n apiEnabled: true,\n apiMethods: ['get', 'list'], // Read-only — audit logs are immutable; creation happens via internal system hooks only\n trash: false, // Never soft-delete audit logs\n mru: false,\n clone: false,\n },\n});\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport type { Plugin, PluginContext } from '@objectstack/core';\nimport { SysAuditLog } from './objects/index.js';\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 namespace: 'sys',\n objects: [SysAuditLog],\n });\n\n // Contribute navigation items to the Setup App (if SetupPlugin is loaded).\n try {\n const setupNav = ctx.getService<{ contribute(c: any): void }>('setupNav');\n if (setupNav) {\n setupNav.contribute({\n areaId: 'area_system',\n items: [\n { id: 'nav_audit_logs', type: 'object', label: 'Audit Logs', objectName: 'audit_log', icon: 'scroll-text', order: 10 },\n ],\n });\n ctx.logger.info('Audit navigation items contributed to Setup App');\n }\n } catch {\n // SetupPlugin not loaded — skip silently\n }\n\n ctx.logger.info('Audit Plugin initialized');\n }\n}\n"],"mappings":";AAEA,SAAS,cAAc,aAAa;AAU7B,IAAM,cAAc,aAAa,OAAO;AAAA,EAC7C,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,EACb,aAAa;AAAA,EACb,eAAe,CAAC,UAAU,eAAe,WAAW,YAAY;AAAA,EAEhE,QAAQ;AAAA,IACN,IAAI,MAAM,KAAK;AAAA,MACb,OAAO;AAAA,MACP,UAAU;AAAA,MACV,UAAU;AAAA,IACZ,CAAC;AAAA,IAED,YAAY,MAAM,SAAS;AAAA,MACzB,OAAO;AAAA,MACP,UAAU;AAAA,MACV,cAAc;AAAA,MACd,UAAU;AAAA,IACZ,CAAC;AAAA,IAED,SAAS,MAAM,KAAK;AAAA,MAClB,OAAO;AAAA,MACP,UAAU;AAAA,MACV,aAAa;AAAA,IACf,CAAC;AAAA,IAED,QAAQ,MAAM,OAAO,CAAC,UAAU,UAAU,UAAU,WAAW,SAAS,UAAU,qBAAqB,iBAAiB,UAAU,QAAQ,GAAG;AAAA,MAC3I,OAAO;AAAA,MACP,UAAU;AAAA,MACV,aAAa;AAAA,IACf,CAAC;AAAA,IAED,aAAa,MAAM,KAAK;AAAA,MACtB,OAAO;AAAA,MACP,UAAU;AAAA,MACV,W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O;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,WAAW;AAAA,MACX,SAAS,CAAC,WAAW;AAAA,IACvB,CAAC;AAGD,QAAI;AACF,YAAM,WAAW,IAAI,WAAyC,UAAU;AACxE,UAAI,UAAU;AACZ,iBAAS,WAAW;AAAA,UAClB,QAAQ;AAAA,UACR,OAAO;AAAA,YACL,EAAE,IAAI,kBAAkB,MAAM,UAAU,OAAO,cAAc,YAAY,aAAa,MAAM,eAAe,OAAO,GAAG;AAAA,UACvH;AAAA,QACF,CAAC;AACD,YAAI,OAAO,KAAK,iDAAiD;AAAA,MACnE;AAAA,IACF,QAAQ;AAAA,IAER;AAEA,QAAI,OAAO,KAAK,0BAA0B;AAAA,EAC5C;AACF;","names":[]}
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",
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.3",
17
- "@objectstack/spec": "4.0.3"
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.0",
21
- "typescript": "^6.0.2",
22
- "vitest": "^4.1.4"
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",
@@ -1,22 +0,0 @@
1
-
2
- > @objectstack/plugin-audit@4.0.3 build /home/runner/work/framework/framework/packages/plugins/plugin-audit
3
- > tsup --config ../../../tsup.config.ts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.1
8
- CLI Using tsup config: /home/runner/work/framework/framework/tsup.config.ts
9
- CLI Target: es2020
10
- CLI Cleaning output folder
11
- ESM Build start
12
- CJS Build start
13
- CJS dist/index.js 4.93 KB
14
- CJS dist/index.js.map 7.55 KB
15
- CJS ⚡️ Build success in 52ms
16
- ESM dist/index.mjs 3.75 KB
17
- ESM dist/index.mjs.map 7.10 KB
18
- ESM ⚡️ Build success in 52ms
19
- DTS Build start
20
- DTS ⚡️ Build success in 15350ms
21
- DTS dist/index.d.mts 103.78 KB
22
- DTS dist/index.d.ts 103.78 KB
package/CHANGELOG.md DELETED
@@ -1,65 +0,0 @@
1
- # @objectstack/plugin-audit
2
-
3
- ## 4.0.3
4
-
5
- ### Patch Changes
6
-
7
- - @objectstack/spec@4.0.3
8
- - @objectstack/core@4.0.3
9
-
10
- ## 4.0.2
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [5f659e9]
15
- - @objectstack/spec@4.0.2
16
- - @objectstack/core@4.0.2
17
-
18
- ## 4.0.0
19
-
20
- ### Patch Changes
21
-
22
- - Updated dependencies [f08ffc3]
23
- - Updated dependencies [e0b0a78]
24
- - @objectstack/spec@4.0.0
25
- - @objectstack/core@4.0.0
26
-
27
- ## 3.3.1
28
-
29
- ### Patch Changes
30
-
31
- - @objectstack/spec@3.3.1
32
- - @objectstack/core@3.3.1
33
-
34
- ## 3.2.10
35
-
36
- ### Patch Changes
37
-
38
- - @objectstack/spec@3.3.0
39
- - @objectstack/core@3.3.0
40
-
41
- ## 3.2.9
42
-
43
- ### Patch Changes
44
-
45
- - @objectstack/spec@3.2.9
46
- - @objectstack/core@3.2.9
47
-
48
- ## 3.2.8
49
-
50
- ### Patch Changes
51
-
52
- - @objectstack/spec@3.2.8
53
- - @objectstack/core@3.2.8
54
-
55
- ## 3.2.7
56
-
57
- ### Patch Changes
58
-
59
- - @objectstack/spec@3.2.7
60
-
61
- ## 3.2.6
62
-
63
- ### Patch Changes
64
-
65
- - @objectstack/spec@3.2.6
@@ -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';
@@ -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
- });
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src",
6
- "types": [
7
- "node"
8
- ]
9
- },
10
- "include": [
11
- "src/**/*"
12
- ],
13
- "exclude": [
14
- "dist",
15
- "node_modules",
16
- "**/*.test.ts"
17
- ]
18
- }