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
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"jest": true
},
"rules": {
"arrow-parens": ["error", "as-needed"],
"@typescript-eslint/lines-between-class-members": "off",
"max-len": "off",
"class-methods-use-this": "off",
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 1.5.0

`ContentAttachments` fixes for all attachments. ([#23](https://github.com/MrRefactoring/confluence.js/issues/23) Thanks [Anton](https://github.com/tester22) for catching)

### 1.4.1

- Dependencies updated.
Expand Down
333 changes: 173 additions & 160 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "confluence.js",
"version": "1.4.1",
"version": "1.5.0",
"description": "confluence.js is a powerful Node.JS/Browser module that allows you to interact with the Confluence API very easily",
"author": "Vladislav Tupikin <mrrefactoring@yandex.ru>",
"license": "MIT",
Expand All @@ -14,7 +14,7 @@
"test": "npm run test:unit && npm run test:e2e",
"prettier": "prettier --write src/**/*.ts",
"doc": "typedoc --name \"Confluence.js - Cloud and Server API library\" --out docs ./src/index.ts --plugin typedoc-plugin-extras --footerDate --footerTime --footerTypedocVersion --favicon https://svgshare.com/i/bVi.svg",
"lint": "eslint src --ext .ts",
"lint": "eslint src tests --ext .ts",
"lint:fix": "npm run lint -- --fix",
"test:unit": "ava tests/unit",
"test:e2e": "ava --timeout=2m --fail-fast --no-worker-threads -c 1 -s tests/e2e/**/*.test.ts"
Expand All @@ -36,34 +36,36 @@
"api",
"wrapper",
"client",
"cloud",
"rest",
"wiki",
"atlassian"
],
"devDependencies": {
"@swc-node/register": "^1.4.2",
"@swc-node/register": "^1.5.1",
"@types/express": "^4.17.13",
"@types/oauth": "^0.9.1",
"@types/sinon": "^10.0.11",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"ava": "^4.2.0",
"dotenv": "^16.0.0",
"eslint": "^8.14.0",
"dotenv": "^16.0.1",
"eslint": "^8.16.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.26.0",
"prettier": "^2.6.2",
"prettier-plugin-jsdoc": "^0.3.38",
"sinon": "^13.0.2",
"sinon": "^14.0.0",
"typedoc": "^0.22.15",
"typedoc-plugin-extras": "^2.2.3",
"typescript": "^4.6.3"
"typescript": "^4.6.4"
},
"dependencies": {
"atlassian-jwt": "^2.0.2",
"axios": "^0.27.0",
"axios": "^0.27.2",
"form-data": "^4.0.0",
"oauth": "^0.9.15",
"tslib": "^2.4.0"
}
Expand Down
282 changes: 85 additions & 197 deletions src/api/contentAttachments.ts

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions src/api/models/attachment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { AttachmentMetadata } from './attachmentMetadata';
import { GenericLinks } from './genericLinks';

export interface Attachment {
id: string;
type: 'attachment' | string;
status: 'current' | string;
title: string;
macroRenderedOutput: any;
metadata: AttachmentMetadata;
extensions: {
mediaType: string;
fileSize: number;
comment: string;
mediaTypeDescription: string;
fileId: string;
};
_expandable: {
childTypes: string;
operations: string;
schedulePublishDate: string;
children: string;
restrictions: string;
history: string;
ancestors: string;
body: string;
descendants: string;
space: string;
};
_links: GenericLinks;
}
28 changes: 28 additions & 0 deletions src/api/models/attachmentContainer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { GenericLinks } from './genericLinks';

export interface AttachmentContainer {
id: string;
type: 'page' | 'string';
status: 'current' | string;
title: string;
macroRenderedOutput: any;
extensions: {
position: number;
};
_expandable: {
container: string;
metadata: string;
restrictions: string;
history:string;
body: string;
version: string;
descendants: string;
space: string;
childTypes: string;
operations: string;
schedulePublishDate: string;
children: string;
ancestors: string;
};
_links: GenericLinks;
}
21 changes: 21 additions & 0 deletions src/api/models/attachmentMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { GenericLinks } from './genericLinks';

export interface AttachmentMetadata {
comment: string;
mediaType: string;
labels: {
results: string[];
start: number;
limit: number;
size: number;
_links: GenericLinks;
};
_expandable: {
currentuser: string;
comments: string;
simple: string;
properties: string;
frontend: string;
likes: string;
};
}
1 change: 1 addition & 0 deletions src/api/models/attachmentUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @deprecated will be removed in second major version */
export interface AttachmentUpdate {
/**
* The attachment version. Set this to the current version number of the attachment. Note, the version number only
Expand Down
8 changes: 4 additions & 4 deletions src/api/models/contentArray.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Content } from './content';
import { GenericLinks } from './genericLinks';

export interface ContentArray {
results: Content[];
start: number;
limit: number;
export interface ContentArray<T = Content> {
results: T[];
start?: number;
limit?: number;
size: number;
_links: GenericLinks;
}
8 changes: 8 additions & 0 deletions src/api/models/createdAttachment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Attachment } from './attachment';
import { AttachmentContainer } from './attachmentContainer';
import { Version } from './version';

export interface CreatedAttachment extends Attachment {
version: Version;
container: AttachmentContainer;
}
13 changes: 12 additions & 1 deletion src/api/models/genericLinks.ts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
export type GenericLinks = Record<string, any>;
export type GenericLinks = {
[key: string]: any;

self: string;
next?: string;
tinyui?: string;
editui?: string;
webui?: string;
base?: string;
context?: string;
download?: string;
};
4 changes: 4 additions & 0 deletions src/api/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ export * from './accountIdEmailRecordArray';
export * from './addContentRestriction';
export * from './addContentRestrictionUpdateArray';
export * from './affectedObject';
export * from './attachmentContainer';
export * from './attachmentUpdate';
export * from './auditRecord';
export * from './auditRecordArray';
export * from './auditRecordCreate';
export * from './appDescriptor';
export * from './attachment';
export * from './attachmentMetadata';
export * from './blueprintTemplate';
export * from './blueprintTemplateArray';
export * from './breadcrumb';
Expand Down Expand Up @@ -60,6 +63,7 @@ export * from './copyPageRequest';
export * from './copyPageRequestDestination';
export * from './cQLPersonalDataConvertedQueries';
export * from './cQLPersonalDataMigrationRequest';
export * from './createdAttachment';
export * from './deletedSpace';
export * from './dynamicModulesErrorMessage';
export * from './embeddable';
Expand Down
14 changes: 12 additions & 2 deletions src/api/parameters/createAttachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ export interface CreateAttachments {
/** The ID of the content to add the attachment to. */
id: string;
/** The status of the content that the attachment is being added to. */
status?: string;
status?: 'current' | 'draft' | string;
/** The attachments to be created. */
attachments: CreateAttachments.Attachment | CreateAttachments.Attachment[];
}

[key: string]: any;
export namespace CreateAttachments {
export interface Attachment {
file: Buffer | ReadableStream | string | Blob | File | any;
filename: string;
minorEdit: boolean;
contentType?: string;
comment?: string;
}
}
7 changes: 5 additions & 2 deletions src/api/parameters/createOrUpdateAttachments.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { CreateAttachments } from './createAttachments';

export interface CreateOrUpdateAttachments {
/** The ID of the content to add the attachment to. */
id: string;
/** The status of the content that the attachment is being added to. This should always be set to 'current'. */
status?: string;
status?: 'current' | 'draft' | string;

[key: string]: any;
/** The attachments to be created or updated. */
attachments: CreateAttachments.Attachment | CreateAttachments.Attachment[];
}
72 changes: 71 additions & 1 deletion src/api/parameters/getAttachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,77 @@ export interface GetAttachments {
/** The ID of the content to be queried for its attachments. */
id: string;
/** A multi-value parameter indicating which properties of the content to expand. */
expand?: string | string[] | GetAttachments.Expand | GetAttachments.Expand[];
expand?:
| 'childTypes.all'
| 'childTypes.attachment'
| 'childTypes.comment'
| 'childTypes.page'
| 'container'
| 'metadata'
| 'metadata.currentuser'
| 'metadata.properties'
| 'metadata.labels'
| 'metadata.frontend'
| 'operations'
| 'children.page'
| 'children.attachment'
| 'children.comment'
| 'restrictions.read.restrictions.user'
| 'restrictions.read.restrictions.group'
| 'restrictions.update.restrictions.user'
| 'restrictions.update.restrictions.group'
| 'history'
| 'history.lastUpdated'
| 'history.previousVersion'
| 'history.contributors'
| 'history.nextVersion'
| 'ancestors'
| 'body'
| 'version'
| 'descendants.page'
| 'descendants.attachment'
| 'descendants.comment'
| 'space'
| 'extensions.inlineProperties'
| 'extensions.resolution'
| (
| 'childTypes.all'
| 'childTypes.attachment'
| 'childTypes.comment'
| 'childTypes.page'
| 'container'
| 'metadata'
| 'metadata.currentuser'
| 'metadata.properties'
| 'metadata.labels'
| 'metadata.frontend'
| 'operations'
| 'children.page'
| 'children.attachment'
| 'children.comment'
| 'restrictions.read.restrictions.user'
| 'restrictions.read.restrictions.group'
| 'restrictions.update.restrictions.user'
| 'restrictions.update.restrictions.group'
| 'history'
| 'history.lastUpdated'
| 'history.previousVersion'
| 'history.contributors'
| 'history.nextVersion'
| 'ancestors'
| 'body'
| 'version'
| 'descendants.page'
| 'descendants.attachment'
| 'descendants.comment'
| 'space'
| 'extensions.inlineProperties'
| 'extensions.resolution'
)[]
| string
| string[]
| GetAttachments.Expand
| GetAttachments.Expand[];
/** The starting index of the returned attachments. */
start?: number;
/** The maximum number of attachments to return per page. Note, this may be restricted by fixed system limits. */
Expand Down
7 changes: 5 additions & 2 deletions src/api/parameters/updateAttachmentData.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { AttachmentUpdate } from '../models';
import { CreateAttachments } from './createAttachments';

export interface UpdateAttachmentData extends AttachmentUpdate {
export interface UpdateAttachmentData {
/** The ID of the content that the attachment is attached to. */
id: string;
/** The ID of the attachment to update. */
attachmentId: string;

/** Attachment data to update. */
attachment: CreateAttachments.Attachment;
}
Loading