Skip to content

Commit dc05fcb

Browse files
authored
Add auditing of what method was used for data imports, updates, deletes (#200)
1 parent e114558 commit dc05fcb

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 1.43.2 - 2025-11-02
2+
- Command and QueryRequestOptions: add auditDetails parameter
3+
14
### 1.43.1 - 2025-10-31
25
- Issue 53449: resolve lineage items from container path
36

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labkey/api",
3-
"version": "1.43.1",
3+
"version": "1.43.2",
44
"description": "JavaScript client API for LabKey Server",
55
"scripts": {
66
"build": "npm run build:dist && npm run build:docs",

src/labkey/dom/Assay.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface ImportRunOptions extends RequestCallbackOptions {
4343
allowLookupByAlternateKey?: boolean;
4444
assayId?: number | string;
4545
auditUserComment?: string;
46+
auditDetails?: Record<string, any>;
4647
batchId?: number | string;
4748
batchProperties?: Record<string, any>;
4849
comment?: string;
@@ -136,6 +137,9 @@ export function importRun(options: ImportRunOptions): XMLHttpRequest {
136137
if (options.auditUserComment !== undefined) {
137138
formData.append('auditUserComment', options.auditUserComment);
138139
}
140+
if (options.auditDetails !== undefined) {
141+
formData.append('auditDetails', JSON.stringify(options.auditDetails));
142+
}
139143

140144
appendProperties('batchProperties', formData, options.batchProperties);
141145
appendProperties('properties', formData, options.properties);

src/labkey/dom/Query.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export function exportTables(options: IExportTablesOptions): void {
9595
}
9696

9797
export interface IImportDataOptions {
98+
auditDetails?: Record<string, any>;
9899
auditUserComment?: string;
99100
containerPath?: string;
100101
failure?: Function;
@@ -161,6 +162,9 @@ export function importData(options: IImportDataOptions): XMLHttpRequest {
161162
if (options.auditUserComment !== undefined) {
162163
form.append('auditUserComment', options.auditUserComment);
163164
}
165+
if (options.auditDetails !== undefined) {
166+
form.append('auditDetails', JSON.stringify(options.auditDetails));
167+
}
164168

165169
if (options.file) {
166170
if (options.file instanceof File) {

src/labkey/query/Rows.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export interface QueryRequestOptions extends RequestCallbackOptions {
2222
apiVersion?: number | string;
2323
/** Can be used to override the audit behavior for the table the query is acting on. See {@link AuditBehaviorTypes}. */
2424
auditBehavior?: AuditBehaviorTypes;
25+
/** Optional audit details to record in the transaction audit log for this command. */
26+
auditDetails?: Record<string, any>;
2527
/** Can be used to provide a comment from the user that will be attached to certain detailed audit log records. */
2628
auditUserComment?: string;
2729
/**
@@ -213,6 +215,10 @@ export interface ModifyRowsResults {
213215
export interface Command {
214216
/** Can be used to override the audit behavior for the table the Command is acting on. See{@link AuditBehaviorTypes}. */
215217
auditBehavior?: AuditBehaviorTypes;
218+
219+
/** Optional audit details to record in the transaction audit log for this command. */
220+
auditDetails?: Record<string, any>;
221+
216222
/** Can be used to provide a comment from the user that will be attached to certain detailed audit log records. */
217223
auditUserComment?: string;
218224
/** Name of the command to be performed. Must be one of "insert", "update", or "delete". */
@@ -267,6 +273,11 @@ export interface SaveRowsResponse {
267273
}
268274

269275
export interface SaveRowsOptions extends RequestCallbackOptions<SaveRowsResponse> {
276+
277+
/**
278+
* Optional audit details to record in the transaction audit log for this command.
279+
*/
280+
auditDetails?: Record<string, any>;
270281
/**
271282
* Version of the API. If this is 13.2 or higher, a request that fails
272283
* validation will be returned as a successful response. Use the 'errorCount' and 'committed' properties in the
@@ -364,6 +375,7 @@ export function saveRows(options: SaveRowsOptions): XMLHttpRequest {
364375
// options = queryArguments(arguments);
365376
// }
366377
const jsonData = {
378+
auditDetails: options.auditDetails,
367379
apiVersion: options.apiVersion,
368380
commands: options.commands,
369381
containerPath: options.containerPath,
@@ -449,6 +461,7 @@ function sendRequest(options: SendRequestOptions, supportsFiles?: boolean): XMLH
449461
transacted: options.transacted,
450462
extraContext: options.extraContext,
451463
auditBehavior: options.auditBehavior,
464+
auditDetails: options.auditDetails,
452465
auditUserComment: options.auditUserComment,
453466
skipReselectRows: options.skipReselectRows,
454467
};
@@ -517,6 +530,7 @@ export function moveRows(options: MoveRowsOptions): XMLHttpRequest {
517530
queryName: options.queryName,
518531
rows: options.rows,
519532
auditBehavior: options.auditBehavior,
533+
auditDetails: options.auditDetails,
520534
auditUserComment: options.auditUserComment,
521535
dataRegionSelectionKey: options.dataRegionSelectionKey,
522536
useSnapshotSelection: options.useSnapshotSelection,

0 commit comments

Comments
 (0)