Skip to content

Commit 1656264

Browse files
authored
Merge pull request #290 from contentstack/fix/DX-2305
DX - 2305 - Added Audit Log to the Stack class and fixed the test cases
2 parents 205970c + 0639794 commit 1656264

File tree

9 files changed

+88
-2258
lines changed

9 files changed

+88
-2258
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [v1.19.5](https://github.com/contentstack/contentstack-management-javascript/tree/v1.19.5) (2025-03-17)
4+
- Fix
5+
- Added AuditLog in the stack class
6+
- Fixed the Unit Test cases and added sanity test case for audit log
7+
38
## [v1.19.4](https://github.com/contentstack/contentstack-management-javascript/tree/v1.19.4) (2025-03-10)
49
- Fix
510
- added fix for variants import

lib/stack/auditlog/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function AuditLog (http, data = {}) {
3636
} || {}
3737
const response = await http.get(this.urlPath, headers)
3838
if (response.data) {
39-
return new AuditLog(http, parseData(response, this.stackHeaders))
39+
return response.data
4040
} else {
4141
throw error(response)
4242
}

lib/stack/index.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,30 @@ export function Stack (http, data) {
810810
*
811811
*/
812812
this.delete = deleteEntity(http)
813+
814+
/**
815+
* @description Audit log displays a record of all the activities performed in a stack and helps you keep a track of all published items, updates, deletes, and current status of the existing content.
816+
* @param {String}
817+
* @returns {AuditLog}
818+
*
819+
* @example
820+
* import * as contentstack from '@contentstack/management'
821+
* const client = contentstack.client()
822+
*
823+
* client.stack({ api_key: 'api_key'}).auditLog().fetchAll()
824+
* .then((logs) => console.log(logs))
825+
*
826+
* client.stack({ api_key: 'api_key' }).auditLog('log_item_uid').fetch()
827+
* .then((log) => console.log(log))
828+
*
829+
*/
830+
this.auditLog = (logItemUid = null) => {
831+
const data = { stackHeaders: this.stackHeaders }
832+
if (logItemUid) {
833+
data.logs = { uid: logItemUid }
834+
}
835+
return new AuditLog(http, data)
836+
}
813837
} else {
814838
/**
815839
* @description The Create stack call creates a new stack in your Contentstack account.
@@ -845,30 +869,6 @@ export function Stack (http, data) {
845869
* .then((stack) => console.log(stack))
846870
*/
847871
this.query = query({ http: http, wrapperCollection: StackCollection })
848-
849-
/**
850-
* @description Audit log displays a record of all the activities performed in a stack and helps you keep a track of all published items, updates, deletes, and current status of the existing content.
851-
* @param {String}
852-
* @returns {AuditLog}
853-
*
854-
* @example
855-
* import * as contentstack from '@contentstack/management'
856-
* const client = contentstack.client()
857-
*
858-
* client.stack({ api_key: 'api_key'}).auditLog().fetchAll()
859-
* .then((logs) => console.log(logs))
860-
*
861-
* client.stack({ api_key: 'api_key' }).auditLog('log_item_uid').fetch()
862-
* .then((log) => console.log(log))
863-
*
864-
*/
865-
this.auditLog = (logItemUid = null) => {
866-
const data = { stackHeaders: this.stackHeaders }
867-
if (logItemUid) {
868-
data.logs = { uid: logItemUid }
869-
}
870-
return new AuditLog(http, data)
871-
}
872872
}
873873
return this
874874
}

0 commit comments

Comments
 (0)