diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..ac69729c3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "data/types"] + path = data/types + url = https://github.com/ChlodAlejandro/deputy-dispatch-types.git diff --git a/data/types b/data/types new file mode 160000 index 000000000..c97487d53 --- /dev/null +++ b/data/types @@ -0,0 +1 @@ +Subproject commit c97487d5315e6ef680e0b93d2d662a1105731f0d diff --git a/src/api/Dispatch.ts b/src/api/Dispatch.ts index f0b508011..6f8135e1e 100644 --- a/src/api/Dispatch.ts +++ b/src/api/Dispatch.ts @@ -1,6 +1,4 @@ -import { ExpandedRevisionData } from './ExpandedRevisionData'; -import Requester from '../util/Requester'; -import { deputyVersion } from '../DeputyVersion'; +import WikiConfiguration from '../config/WikiConfiguration'; /** * API communication class @@ -51,7 +49,7 @@ export default class Dispatch { async getEndpoint( endpoint: string ): Promise { return new URL( endpoint.replace( /^\/+/, '' ), - ( await window.deputy.getWikiConfig() ).core.dispatchRoot.get() + ( await WikiConfiguration.load() ).core.dispatchRoot.get() .href .replace( /\/+$/, '' ) ); diff --git a/src/api/DispatchAsync.ts b/src/api/DispatchAsync.ts index 6a402efc0..5adadabd4 100644 --- a/src/api/DispatchAsync.ts +++ b/src/api/DispatchAsync.ts @@ -4,7 +4,7 @@ interface DeputyDispatchTaskOptions { /** * The rate in milliseconds at which new progress requests are made. * - * @default 500 + * @default 1000 */ refreshRate?: number; } @@ -54,7 +54,7 @@ export class DeputyDispatchTask extends EventTarget implements DeputyDispatch } this.id = id; - this.refreshRate = options.refreshRate ?? 500; + this.refreshRate = options.refreshRate ?? 1000; // Execute last. this.promise = this.waitUntilDone(); @@ -125,6 +125,7 @@ export default class DispatchAsync { taskOptions: DeputyDispatchTaskOptions = {} ): Promise> { const taskInfo = await fetch( endpoint, { + method: 'POST', body: JSON.stringify( options ), headers: { 'Content-Type': 'application/json', diff --git a/src/api/DispatchUser.ts b/src/api/DispatchUser.ts index 0ebd03cb7..3fd38adce 100644 --- a/src/api/DispatchUser.ts +++ b/src/api/DispatchUser.ts @@ -1,5 +1,6 @@ import Dispatch from './Dispatch'; import DispatchAsync, { DeputyDispatchTask } from './DispatchAsync'; +import { DispatchUserDeletedPagesResponse } from './types/DispatchTypes'; /** * @@ -20,7 +21,8 @@ export default class DispatchUser { * * @param user */ - async deletedPages( user: string ): Promise> { + async deletedPages( user: string ): + Promise> { const endpoint = await Dispatch.i.getEndpoint( 'v1/user/deleted-pages' ); return ( await DispatchAsync.makeRequest( endpoint, { user, diff --git a/src/api/ExpandedRevisionData.ts b/src/api/ExpandedRevisionData.ts index 4834cd318..9a067104f 100644 --- a/src/api/ExpandedRevisionData.ts +++ b/src/api/ExpandedRevisionData.ts @@ -7,6 +7,10 @@ export interface RevisionData { size: number; comment: string; tags: string[]; + + commenthidden?: true; + userhidden?: true; + texthidden?: true; } export interface ExpandedRevisionData extends RevisionData { diff --git a/src/api/models b/src/api/models new file mode 120000 index 000000000..59c885380 --- /dev/null +++ b/src/api/models @@ -0,0 +1 @@ +../../data/types/models \ No newline at end of file diff --git a/src/api/types/DispatchTypes.ts b/src/api/types/DispatchTypes.ts new file mode 100644 index 000000000..de6def71e --- /dev/null +++ b/src/api/types/DispatchTypes.ts @@ -0,0 +1,13 @@ +import type { DeletedPage } from '../models/DeletedPage'; +import type { DeletedRevision } from '../models/DeletedRevision'; + +export interface DispatchUserDeletedPagesResponse { + + pages: DeletedPage[]; + +} +export interface DispatchUserDeletedRevisionsResponse { + + revisions: DeletedRevision[]; + +}