chore: API Consistency (#1304)

* chore: Addressing API inconsistencies

* lint

* add: Missing sort to groups.list
fix: Documention issues

* test: fix

* feat: Add missing shares.info endpoint

* feat: Add sorting to users.list endpoint

* fix: Incorrect pagination parameters listed on user endpoints

* users.s3Upload -> attachments.create

* chore: exportAll -> export_all
This commit is contained in:
Tom Moor
2020-06-16 20:56:17 -07:00
committed by GitHub
parent 5010b08e83
commit 0f8d503df8
20 changed files with 309 additions and 250 deletions

View File

@@ -42,7 +42,7 @@ class DocumentHistory extends React.Component<Props> {
const results = await this.props.revisions.fetchPage({
limit,
offset: this.offset,
id: this.props.match.params.documentSlug,
documentId: this.props.match.params.documentSlug,
});
if (

View File

@@ -267,7 +267,7 @@ class CollectionScene extends React.Component<Props> {
collection.id
)}
fetch={documents.fetchAlphabetical}
options={{ collection: collection.id }}
options={{ collectionId: collection.id }}
showPin
/>
</Route>
@@ -278,7 +278,7 @@ class CollectionScene extends React.Component<Props> {
collection.id
)}
fetch={documents.fetchLeastRecentlyUpdated}
options={{ collection: collection.id }}
options={{ collectionId: collection.id }}
showPin
/>
</Route>
@@ -289,7 +289,7 @@ class CollectionScene extends React.Component<Props> {
collection.id
)}
fetch={documents.fetchRecentlyPublished}
options={{ collection: collection.id }}
options={{ collectionId: collection.id }}
showPublished
showPin
/>
@@ -300,7 +300,7 @@ class CollectionScene extends React.Component<Props> {
collection.id
)}
fetch={documents.fetchRecentlyUpdated}
options={{ collection: collection.id }}
options={{ collectionId: collection.id }}
showPin
/>
</Route>

View File

@@ -97,11 +97,8 @@ class DataLoader extends React.Component<Props> {
};
loadRevision = async () => {
const { documentSlug, revisionId } = this.props.match.params;
this.revision = await this.props.revisions.fetch(documentSlug, {
revisionId,
});
const { revisionId } = this.props.match.params;
this.revision = await this.props.revisions.fetch(revisionId);
};
loadDocument = async () => {

View File

@@ -105,6 +105,6 @@ export default class CollectionsStore extends BaseStore<Collection> {
}
export = () => {
return client.post('/collections.exportAll');
return client.post('/collections.export_all');
};
}

View File

@@ -20,21 +20,16 @@ export default class RevisionsStore extends BaseStore<Revision> {
}
@action
fetch = async (
documentId: string,
options?: FetchOptions
): Promise<?Revision> => {
fetch = async (id: string, options?: FetchOptions): Promise<?Revision> => {
this.isFetching = true;
const id = options && options.revisionId;
if (!id) throw new Error('revisionId is required');
invariant(id, 'Id is required');
try {
const rev = this.data.get(id);
if (rev) return rev;
const res = await client.post('/documents.revision', {
id: documentId,
revisionId: id,
const res = await client.post('/revisions.info', {
id,
});
invariant(res && res.data, 'Revision not available');
this.add(res.data);
@@ -54,7 +49,7 @@ export default class RevisionsStore extends BaseStore<Revision> {
this.isFetching = true;
try {
const res = await client.post('/documents.revisions', options);
const res = await client.post('/revisions.list', options);
invariant(res && res.data, 'Document revisions not available');
runInAction('RevisionsStore#fetchPage', () => {
res.data.forEach(revision => this.add(revision));

View File

@@ -13,7 +13,7 @@ export const uploadFile = async (
options?: Options = { name: '' }
) => {
const name = file instanceof File ? file.name : options.name;
const response = await client.post('/users.s3Upload', {
const response = await client.post('/attachments.create', {
public: options.public,
documentId: options.documentId,
contentType: file.type,
@@ -24,7 +24,7 @@ export const uploadFile = async (
invariant(response, 'Response should be available');
const data = response.data;
const asset = data.asset;
const attachment = data.attachment;
const formData = new FormData();
for (const key in data.form) {
@@ -44,7 +44,7 @@ export const uploadFile = async (
body: formData,
});
return asset;
return attachment;
};
export const dataUrlToBlob = (dataURL: string) => {