mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-26 20:53:09 +02:00
add
This commit is contained in:
parent
8122cb3a86
commit
019199168e
4 changed files with 106 additions and 112 deletions
|
@ -5,40 +5,10 @@ import { QueryService } from '@/core/QueryService.js';
|
|||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['drive'],
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'read:drive',
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'DriveFile',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||
type: { type: 'string', nullable: true, pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) },
|
||||
sort: { type: 'string', nullable: true, enum: ['+createdAt', '-createdAt', '+name', '-name', '+size', '-size'] },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
export default class extends Endpoint<'drive/files'> {
|
||||
name = 'drive/files' as const;
|
||||
constructor(
|
||||
@Inject(DI.driveFilesRepository)
|
||||
private driveFilesRepository: DriveFilesRepository,
|
||||
|
@ -46,7 +16,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
private driveFileEntityService: DriveFileEntityService,
|
||||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
super(async (ps, me) => {
|
||||
const query = this.queryService.makePaginationQuery(this.driveFilesRepository.createQueryBuilder('file'), ps.sinceId, ps.untilId)
|
||||
.andWhere('file.userId = :userId', { userId: me.id });
|
||||
|
||||
|
|
|
@ -5,38 +5,10 @@ import { QueryService } from '@/core/QueryService.js';
|
|||
import { DriveFolderEntityService } from '@/core/entities/DriveFolderEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['drive'],
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'read:drive',
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'DriveFolder',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
export default class extends Endpoint<'drive/folders'> {
|
||||
name = 'drive/folders' as const;
|
||||
constructor(
|
||||
@Inject(DI.driveFoldersRepository)
|
||||
private driveFoldersRepository: DriveFoldersRepository,
|
||||
|
@ -44,7 +16,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
private driveFolderEntityService: DriveFolderEntityService,
|
||||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
super(async (ps, me) => {
|
||||
const query = this.queryService.makePaginationQuery(this.driveFoldersRepository.createQueryBuilder('folder'), ps.sinceId, ps.untilId)
|
||||
.andWhere('folder.userId = :userId', { userId: me.id });
|
||||
|
||||
|
|
|
@ -5,38 +5,10 @@ import { QueryService } from '@/core/QueryService.js';
|
|||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['drive'],
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'read:drive',
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'DriveFile',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
type: { type: 'string', pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
export default class extends Endpoint<'drive/stream'> {
|
||||
name = 'drive/stream' as const;
|
||||
constructor(
|
||||
@Inject(DI.driveFilesRepository)
|
||||
private driveFilesRepository: DriveFilesRepository,
|
||||
|
@ -44,7 +16,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
private driveFileEntityService: DriveFileEntityService,
|
||||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
super(async (ps, me) => {
|
||||
const query = this.queryService.makePaginationQuery(this.driveFilesRepository.createQueryBuilder('file'), ps.sinceId, ps.untilId)
|
||||
.andWhere('file.userId = :userId', { userId: me.id });
|
||||
|
||||
|
|
|
@ -3916,16 +3916,16 @@ export const endpoints = {
|
|||
},
|
||||
'drive/folders/create': {
|
||||
tags: ['drive'],
|
||||
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
|
||||
kind: 'write:drive',
|
||||
|
||||
|
||||
limit: {
|
||||
duration: ms('1hour'),
|
||||
max: 10,
|
||||
},
|
||||
|
||||
|
||||
errors: {
|
||||
noSuchFolder: {
|
||||
message: 'No such folder.',
|
||||
|
@ -3955,18 +3955,18 @@ export const endpoints = {
|
|||
},
|
||||
'drive/folders/delete': {
|
||||
tags: ['drive'],
|
||||
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
|
||||
kind: 'write:drive',
|
||||
|
||||
|
||||
errors: {
|
||||
noSuchFolder: {
|
||||
message: 'No such folder.',
|
||||
code: 'NO_SUCH_FOLDER',
|
||||
id: '1069098f-c281-440f-b085-f9932edbe091',
|
||||
},
|
||||
|
||||
|
||||
hasChildFilesOrFolders: {
|
||||
message: 'This folder has child files or folders.',
|
||||
code: 'HAS_CHILD_FILES_OR_FOLDERS',
|
||||
|
@ -3987,9 +3987,9 @@ export const endpoints = {
|
|||
},
|
||||
'drive/folders/find': {
|
||||
tags: ['drive'],
|
||||
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
|
||||
kind: 'read:drive',
|
||||
|
||||
defines: [{
|
||||
|
@ -4017,9 +4017,9 @@ export const endpoints = {
|
|||
},
|
||||
'drive/folders/show': {
|
||||
tags: ['drive'],
|
||||
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
|
||||
kind: 'read:drive',
|
||||
|
||||
errors: {
|
||||
|
@ -4045,24 +4045,24 @@ export const endpoints = {
|
|||
},
|
||||
'drive/folders/update': {
|
||||
tags: ['drive'],
|
||||
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
|
||||
kind: 'write:drive',
|
||||
|
||||
|
||||
errors: {
|
||||
noSuchFolder: {
|
||||
message: 'No such folder.',
|
||||
code: 'NO_SUCH_FOLDER',
|
||||
id: 'f7974dac-2c0d-4a27-926e-23583b28e98e',
|
||||
},
|
||||
|
||||
|
||||
noSuchParentFolder: {
|
||||
message: 'No such parent folder.',
|
||||
code: 'NO_SUCH_PARENT_FOLDER',
|
||||
id: 'ce104e3a-faaf-49d5-b459-10ff0cbbcaa1',
|
||||
},
|
||||
|
||||
|
||||
recursiveNesting: {
|
||||
message: 'It can not be structured like nesting folders recursively.',
|
||||
code: 'RECURSIVE_NESTING',
|
||||
|
@ -4090,6 +4090,86 @@ export const endpoints = {
|
|||
}
|
||||
}],
|
||||
},
|
||||
'drive/files': {
|
||||
tags: ['drive'],
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'read:drive',
|
||||
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||
type: { type: 'string', nullable: true, pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) },
|
||||
sort: { type: 'string', nullable: true, enum: ['+createdAt', '-createdAt', '+name', '-name', '+size', '-size'] },
|
||||
},
|
||||
required: [],
|
||||
},
|
||||
res: {
|
||||
type: 'array',
|
||||
items: {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/DriveFile',
|
||||
},
|
||||
},
|
||||
}],
|
||||
},
|
||||
'drive/folders': {
|
||||
tags: ['drive'],
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'read:drive',
|
||||
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||
},
|
||||
required: [],
|
||||
},
|
||||
res: {
|
||||
type: 'array',
|
||||
items: {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/DriveFolder',
|
||||
},
|
||||
},
|
||||
}],
|
||||
},
|
||||
'drive/stream': {
|
||||
tags: ['drive'],
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'read:drive',
|
||||
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
type: { type: 'string', pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) },
|
||||
},
|
||||
required: [],
|
||||
},
|
||||
res: {
|
||||
type: 'array',
|
||||
items: {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/DriveFile',
|
||||
},
|
||||
},
|
||||
}],
|
||||
},
|
||||
//#endregion
|
||||
} as const satisfies { [x: string]: IEndpointMeta; };
|
||||
|
||||
|
|
Loading…
Reference in a new issue