add
This commit is contained in:
parent
8122cb3a86
commit
019199168e
|
@ -5,40 +5,10 @@ import { QueryService } from '@/core/QueryService.js';
|
||||||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||||
import { DI } from '@/di-symbols.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<'drive/files'> {
|
||||||
|
name = 'drive/files' as const;
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.driveFilesRepository)
|
@Inject(DI.driveFilesRepository)
|
||||||
private driveFilesRepository: DriveFilesRepository,
|
private driveFilesRepository: DriveFilesRepository,
|
||||||
|
@ -46,7 +16,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
private driveFileEntityService: DriveFileEntityService,
|
private driveFileEntityService: DriveFileEntityService,
|
||||||
private queryService: QueryService,
|
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)
|
const query = this.queryService.makePaginationQuery(this.driveFilesRepository.createQueryBuilder('file'), ps.sinceId, ps.untilId)
|
||||||
.andWhere('file.userId = :userId', { userId: me.id });
|
.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 { DriveFolderEntityService } from '@/core/entities/DriveFolderEntityService.js';
|
||||||
import { DI } from '@/di-symbols.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<'drive/folders'> {
|
||||||
|
name = 'drive/folders' as const;
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.driveFoldersRepository)
|
@Inject(DI.driveFoldersRepository)
|
||||||
private driveFoldersRepository: DriveFoldersRepository,
|
private driveFoldersRepository: DriveFoldersRepository,
|
||||||
|
@ -44,7 +16,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
private driveFolderEntityService: DriveFolderEntityService,
|
private driveFolderEntityService: DriveFolderEntityService,
|
||||||
private queryService: QueryService,
|
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)
|
const query = this.queryService.makePaginationQuery(this.driveFoldersRepository.createQueryBuilder('folder'), ps.sinceId, ps.untilId)
|
||||||
.andWhere('folder.userId = :userId', { userId: me.id });
|
.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 { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||||
import { DI } from '@/di-symbols.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<'drive/stream'> {
|
||||||
|
name = 'drive/stream' as const;
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.driveFilesRepository)
|
@Inject(DI.driveFilesRepository)
|
||||||
private driveFilesRepository: DriveFilesRepository,
|
private driveFilesRepository: DriveFilesRepository,
|
||||||
|
@ -44,7 +16,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
private driveFileEntityService: DriveFileEntityService,
|
private driveFileEntityService: DriveFileEntityService,
|
||||||
private queryService: QueryService,
|
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)
|
const query = this.queryService.makePaginationQuery(this.driveFilesRepository.createQueryBuilder('file'), ps.sinceId, ps.untilId)
|
||||||
.andWhere('file.userId = :userId', { userId: me.id });
|
.andWhere('file.userId = :userId', { userId: me.id });
|
||||||
|
|
||||||
|
|
|
@ -3916,16 +3916,16 @@ export const endpoints = {
|
||||||
},
|
},
|
||||||
'drive/folders/create': {
|
'drive/folders/create': {
|
||||||
tags: ['drive'],
|
tags: ['drive'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
|
|
||||||
kind: 'write:drive',
|
kind: 'write:drive',
|
||||||
|
|
||||||
limit: {
|
limit: {
|
||||||
duration: ms('1hour'),
|
duration: ms('1hour'),
|
||||||
max: 10,
|
max: 10,
|
||||||
},
|
},
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchFolder: {
|
noSuchFolder: {
|
||||||
message: 'No such folder.',
|
message: 'No such folder.',
|
||||||
|
@ -3955,18 +3955,18 @@ export const endpoints = {
|
||||||
},
|
},
|
||||||
'drive/folders/delete': {
|
'drive/folders/delete': {
|
||||||
tags: ['drive'],
|
tags: ['drive'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
|
|
||||||
kind: 'write:drive',
|
kind: 'write:drive',
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchFolder: {
|
noSuchFolder: {
|
||||||
message: 'No such folder.',
|
message: 'No such folder.',
|
||||||
code: 'NO_SUCH_FOLDER',
|
code: 'NO_SUCH_FOLDER',
|
||||||
id: '1069098f-c281-440f-b085-f9932edbe091',
|
id: '1069098f-c281-440f-b085-f9932edbe091',
|
||||||
},
|
},
|
||||||
|
|
||||||
hasChildFilesOrFolders: {
|
hasChildFilesOrFolders: {
|
||||||
message: 'This folder has child files or folders.',
|
message: 'This folder has child files or folders.',
|
||||||
code: 'HAS_CHILD_FILES_OR_FOLDERS',
|
code: 'HAS_CHILD_FILES_OR_FOLDERS',
|
||||||
|
@ -3987,9 +3987,9 @@ export const endpoints = {
|
||||||
},
|
},
|
||||||
'drive/folders/find': {
|
'drive/folders/find': {
|
||||||
tags: ['drive'],
|
tags: ['drive'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
|
|
||||||
kind: 'read:drive',
|
kind: 'read:drive',
|
||||||
|
|
||||||
defines: [{
|
defines: [{
|
||||||
|
@ -4017,9 +4017,9 @@ export const endpoints = {
|
||||||
},
|
},
|
||||||
'drive/folders/show': {
|
'drive/folders/show': {
|
||||||
tags: ['drive'],
|
tags: ['drive'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
|
|
||||||
kind: 'read:drive',
|
kind: 'read:drive',
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
|
@ -4045,24 +4045,24 @@ export const endpoints = {
|
||||||
},
|
},
|
||||||
'drive/folders/update': {
|
'drive/folders/update': {
|
||||||
tags: ['drive'],
|
tags: ['drive'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
|
|
||||||
kind: 'write:drive',
|
kind: 'write:drive',
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchFolder: {
|
noSuchFolder: {
|
||||||
message: 'No such folder.',
|
message: 'No such folder.',
|
||||||
code: 'NO_SUCH_FOLDER',
|
code: 'NO_SUCH_FOLDER',
|
||||||
id: 'f7974dac-2c0d-4a27-926e-23583b28e98e',
|
id: 'f7974dac-2c0d-4a27-926e-23583b28e98e',
|
||||||
},
|
},
|
||||||
|
|
||||||
noSuchParentFolder: {
|
noSuchParentFolder: {
|
||||||
message: 'No such parent folder.',
|
message: 'No such parent folder.',
|
||||||
code: 'NO_SUCH_PARENT_FOLDER',
|
code: 'NO_SUCH_PARENT_FOLDER',
|
||||||
id: 'ce104e3a-faaf-49d5-b459-10ff0cbbcaa1',
|
id: 'ce104e3a-faaf-49d5-b459-10ff0cbbcaa1',
|
||||||
},
|
},
|
||||||
|
|
||||||
recursiveNesting: {
|
recursiveNesting: {
|
||||||
message: 'It can not be structured like nesting folders recursively.',
|
message: 'It can not be structured like nesting folders recursively.',
|
||||||
code: 'RECURSIVE_NESTING',
|
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
|
//#endregion
|
||||||
} as const satisfies { [x: string]: IEndpointMeta; };
|
} as const satisfies { [x: string]: IEndpointMeta; };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue