feat: レジストリAPIをサードパーティから利用可能に (#12229)
* wip * wip * Update remove.ts * refactor
This commit is contained in:
@@ -5,13 +5,10 @@
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import type { RegistryItemsRepository } from '@/models/_.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { RegistryApiService } from '@/core/RegistryApiService.js';
|
||||
|
||||
export const meta = {
|
||||
requireCredential: true,
|
||||
|
||||
secure: true,
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
@@ -20,23 +17,18 @@ export const paramDef = {
|
||||
scope: { type: 'array', default: [], items: {
|
||||
type: 'string', pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1),
|
||||
} },
|
||||
domain: { type: 'string', nullable: true },
|
||||
},
|
||||
required: [],
|
||||
required: ['scope'],
|
||||
} as const;
|
||||
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||
constructor(
|
||||
@Inject(DI.registryItemsRepository)
|
||||
private registryItemsRepository: RegistryItemsRepository,
|
||||
private registryApiService: RegistryApiService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const query = this.registryItemsRepository.createQueryBuilder('item')
|
||||
.where('item.domain IS NULL')
|
||||
.andWhere('item.userId = :userId', { userId: me.id })
|
||||
.andWhere('item.scope = :scope', { scope: ps.scope });
|
||||
|
||||
const items = await query.getMany();
|
||||
super(meta, paramDef, async (ps, me, accessToken) => {
|
||||
const items = await this.registryApiService.getAllItemsOfScope(me.id, accessToken != null ? accessToken.id : (ps.domain ?? null), ps.scope);
|
||||
|
||||
const res = {} as Record<string, any>;
|
||||
|
||||
|
Reference in New Issue
Block a user