Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"prettier-plugin-jsdoc"
]
}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

### 1.0.1

- Minor internal improvements
- New endpoint added

### 1.0.0

- Initial upload
1,088 changes: 498 additions & 590 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "confluence.js",
"version": "1.0.0",
"version": "1.0.1",
"description": "confluence.js is a powerful Node.JS/Browser module that allows you to interact with the Confluence API very easily",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand All @@ -10,6 +10,7 @@
"test": "npm run test:unit && npm run test:system",
"test:unit": "jest tests/unit",
"test:system": "jest tests/system --setupFiles=./tests/setup.ts --runInBand",
"prettier": "prettier --write src/**/*.ts",
"doc": "typedoc --name Confluence.js --out docs ./src",
"lint": "eslint src --ext .ts",
"lint:fix": "npm run lint -- --fix"
Expand All @@ -32,25 +33,27 @@
"license": "MIT",
"homepage": "https://github.com/MrRefactoring/confluence.js#readme",
"devDependencies": {
"@types/express": "^4.17.11",
"@types/jest": "^26.0.22",
"@types/express": "^4.17.12",
"@types/jest": "^26.0.23",
"@types/oauth": "^0.9.1",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"dotenv": "^8.2.0",
"eslint": "^7.24.0",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"dotenv": "^10.0.0",
"eslint": "^7.27.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3",
"ts-jest": "^26.5.4",
"typedoc": "^0.20.35",
"eslint-plugin-import": "^2.23.3",
"jest": "^26.0.23",
"prettier": "^2.3.0",
"prettier-plugin-jsdoc": "^0.3.22",
"ts-jest": "^26.5.6",
"typedoc": "^0.20.36",
"typescript": "^4.2.4"
},
"dependencies": {
"atlassian-jwt": "^1.0.3",
"atlassian-jwt": "^2.0.0",
"axios": "^0.21.1",
"oauth": "^0.9.15",
"telemetry.confluence.js": "*"
"telemetry.confluence.js": "<2"
}
}
198 changes: 115 additions & 83 deletions src/api/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,35 @@ import { Callback } from '../callback';
import { RequestConfig } from '../requestConfig';

export class Audit {
constructor(private client: Client) { }
constructor(private client: Client) {}

/**
* Returns all records in the audit log, optionally for a certain date range.
* This contains information about events like space exports, group membership
* changes, app installations, etc. For more information, see
* [Audit log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html)
* in the Confluence administrator's guide.
* Returns all records in the audit log, optionally for a certain date range. This contains information about events
* like space exports, group membership changes, app installations, etc. For more information, see [Audit
* log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html) in the Confluence administrator's guide.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async getAuditRecords<T = Models.AuditRecordArray>(parameters: Parameters.GetAuditRecords | undefined, callback: Callback<T>): Promise<void>;
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async getAuditRecords<T = Models.AuditRecordArray>(
parameters: Parameters.GetAuditRecords | undefined,
callback: Callback<T>
): Promise<void>;
/**
* Returns all records in the audit log, optionally for a certain date range.
* This contains information about events like space exports, group membership
* changes, app installations, etc. For more information, see
* [Audit log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html)
* in the Confluence administrator's guide.
* Returns all records in the audit log, optionally for a certain date range. This contains information about events
* like space exports, group membership changes, app installations, etc. For more information, see [Audit
* log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html) in the Confluence administrator's guide.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async getAuditRecords<T = Models.AuditRecordArray>(parameters?: Parameters.GetAuditRecords, callback?: never): Promise<T>;
async getAuditRecords<T = Models.AuditRecordArray>(parameters?: Parameters.GetAuditRecords, callback?: Callback<T>): Promise<void | T> {
const config = {
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async getAuditRecords<T = Models.AuditRecordArray>(
parameters?: Parameters.GetAuditRecords,
callback?: never
): Promise<T>;
async getAuditRecords<T = Models.AuditRecordArray>(
parameters?: Parameters.GetAuditRecords,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/api/audit',
method: 'GET',
params: {
Expand All @@ -38,25 +43,34 @@ export class Audit {
start: parameters?.start,
limit: parameters?.limit,
},
} as RequestConfig;
};

return this.client.sendRequest(config, callback, { methodName: 'getAuditRecords' });
}

/**
* Creates a record in the audit log.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async createAuditRecord<T = Models.AuditRecord>(parameters: Parameters.CreateAuditRecord | undefined, callback: Callback<T>): Promise<void>;
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async createAuditRecord<T = Models.AuditRecord>(
parameters: Parameters.CreateAuditRecord | undefined,
callback: Callback<T>
): Promise<void>;
/**
* Creates a record in the audit log.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async createAuditRecord<T = Models.AuditRecord>(parameters?: Parameters.CreateAuditRecord, callback?: never): Promise<T>;
async createAuditRecord<T = Models.AuditRecord>(parameters?: Parameters.CreateAuditRecord, callback?: Callback<T>): Promise<void | T> {
const config = {
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async createAuditRecord<T = Models.AuditRecord>(
parameters?: Parameters.CreateAuditRecord,
callback?: never
): Promise<T>;
async createAuditRecord<T = Models.AuditRecord>(
parameters?: Parameters.CreateAuditRecord,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/api/audit',
method: 'POST',
data: {
Expand All @@ -71,25 +85,31 @@ export class Audit {
changedValues: parameters?.changedValues,
associatedObjects: parameters?.associatedObjects,
},
} as RequestConfig;
};

return this.client.sendRequest(config, callback, { methodName: 'createAuditRecord' });
}

/**
* Exports audit records as a CSV file or ZIP file.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async exportAuditRecords<T = unknown>(parameters: Parameters.ExportAuditRecords | undefined, callback: Callback<T>): Promise<void>;
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async exportAuditRecords<T = unknown>(
parameters: Parameters.ExportAuditRecords | undefined,
callback: Callback<T>
): Promise<void>;
/**
* Exports audit records as a CSV file or ZIP file.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async exportAuditRecords<T = unknown>(parameters?: Parameters.ExportAuditRecords, callback?: never): Promise<T>;
async exportAuditRecords<T = unknown>(parameters?: Parameters.ExportAuditRecords, callback?: Callback<T>): Promise<void | T> {
const config = {
async exportAuditRecords<T = unknown>(
parameters?: Parameters.ExportAuditRecords,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/api/audit/export',
method: 'GET',
params: {
Expand All @@ -98,89 +118,101 @@ export class Audit {
searchString: parameters?.searchString,
format: parameters?.format,
},
} as RequestConfig;
};

return this.client.sendRequest(config, callback, { methodName: 'exportAuditRecords' });
}

/**
* Returns the retention period for records in the audit log. The retention
* period is how long an audit record is kept for, from creation date until
* it is deleted.
* Returns the retention period for records in the audit log. The retention period is how long an audit record is kept
* for, from creation date until it is deleted.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async getRetentionPeriod<T = Models.RetentionPeriod>(callback: Callback<T>): Promise<void>;
/**
* Returns the retention period for records in the audit log. The retention
* period is how long an audit record is kept for, from creation date until
* it is deleted.
* Returns the retention period for records in the audit log. The retention period is how long an audit record is kept
* for, from creation date until it is deleted.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async getRetentionPeriod<T = Models.RetentionPeriod>(callback?: never): Promise<T>;
async getRetentionPeriod<T = Models.RetentionPeriod>(callback?: Callback<T>): Promise<void | T> {
const config = {
const config: RequestConfig = {
url: '/api/audit/retention',
method: 'GET',
} as RequestConfig;
};

return this.client.sendRequest(config, callback, { methodName: 'getRetentionPeriod' });
}

/**
* Sets the retention period for records in the audit log. The retention period
* can be set to a maximum of 20 years.
* Sets the retention period for records in the audit log. The retention period can be set to a maximum of 20 years.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async setRetentionPeriod<T = Models.RetentionPeriod>(parameters: Parameters.SetRetentionPeriod | undefined, callback: Callback<T>): Promise<void>;
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async setRetentionPeriod<T = Models.RetentionPeriod>(
parameters: Parameters.SetRetentionPeriod | undefined,
callback: Callback<T>
): Promise<void>;
/**
* Sets the retention period for records in the audit log. The retention period
* can be set to a maximum of 20 years.
* Sets the retention period for records in the audit log. The retention period can be set to a maximum of 20 years.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async setRetentionPeriod<T = Models.RetentionPeriod>(parameters?: Parameters.SetRetentionPeriod, callback?: never): Promise<T>;
async setRetentionPeriod<T = Models.RetentionPeriod>(parameters?: Parameters.SetRetentionPeriod, callback?: Callback<T>): Promise<void | T> {
const config = {
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async setRetentionPeriod<T = Models.RetentionPeriod>(
parameters?: Parameters.SetRetentionPeriod,
callback?: never
): Promise<T>;
async setRetentionPeriod<T = Models.RetentionPeriod>(
parameters?: Parameters.SetRetentionPeriod,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/api/audit/retention',
method: 'PUT',
data: {
number: parameters?.number,
units: parameters?.units,
},
} as RequestConfig;
};

return this.client.sendRequest(config, callback, { methodName: 'setRetentionPeriod' });
}

/**
* Returns records from the audit log, for a time period back from the current
* date. For example, you can use this method to get the last 3 months of records.
* Returns records from the audit log, for a time period back from the current date. For example, you can use this
* method to get the last 3 months of records.
*
* This contains information about events like space exports, group membership
* changes, app installations, etc. For more information, see
* [Audit log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html)
* in the Confluence administrator's guide.
* This contains information about events like space exports, group membership changes, app installations, etc. For
* more information, see [Audit log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html) in the
* Confluence administrator's guide.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async getAuditRecordsForTimePeriod<T = Models.AuditRecordArray>(parameters: Parameters.GetAuditRecordsForTimePeriod | undefined, callback: Callback<T>): Promise<void>;
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async getAuditRecordsForTimePeriod<T = Models.AuditRecordArray>(
parameters: Parameters.GetAuditRecordsForTimePeriod | undefined,
callback: Callback<T>
): Promise<void>;
/**
* Returns records from the audit log, for a time period back from the current
* date. For example, you can use this method to get the last 3 months of records.
* Returns records from the audit log, for a time period back from the current date. For example, you can use this
* method to get the last 3 months of records.
*
* This contains information about events like space exports, group membership
* changes, app installations, etc. For more information, see
* [Audit log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html)
* in the Confluence administrator's guide.
* This contains information about events like space exports, group membership changes, app installations, etc. For
* more information, see [Audit log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html) in the
* Confluence administrator's guide.
*
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
* 'Confluence Administrator' global permission. */
async getAuditRecordsForTimePeriod<T = Models.AuditRecordArray>(parameters?: Parameters.GetAuditRecordsForTimePeriod, callback?: never): Promise<T>;
async getAuditRecordsForTimePeriod<T = Models.AuditRecordArray>(parameters?: Parameters.GetAuditRecordsForTimePeriod, callback?: Callback<T>): Promise<void | T> {
const config = {
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Confluence Administrator' global permission.
*/
async getAuditRecordsForTimePeriod<T = Models.AuditRecordArray>(
parameters?: Parameters.GetAuditRecordsForTimePeriod,
callback?: never
): Promise<T>;
async getAuditRecordsForTimePeriod<T = Models.AuditRecordArray>(
parameters?: Parameters.GetAuditRecordsForTimePeriod,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/api/audit/since',
method: 'GET',
params: {
Expand All @@ -190,7 +222,7 @@ export class Audit {
start: parameters?.start,
limit: parameters?.limit,
},
} as RequestConfig;
};

return this.client.sendRequest(config, callback, { methodName: 'getAuditRecordsForTimePeriod' });
}
Expand Down
Loading