mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-11-09 00:22:38 -06:00
refactor(api-tokens): delete legacy resource stack
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
import type {IAbstract} from '@/modelTypes/IAbstract'
|
||||
|
||||
export interface IApiPermission {
|
||||
[key: string]: string[]
|
||||
}
|
||||
|
||||
export interface IApiToken extends IAbstract {
|
||||
id: number
|
||||
title: string
|
||||
token: string
|
||||
permissions: IApiPermission
|
||||
expiresAt: Date
|
||||
created: Date
|
||||
ownerId?: number
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import type {RouteDetail} from '@/client/generated'
|
||||
|
||||
export type ApiTokenRoutes = Record<string, Record<string, RouteDetail>>
|
||||
export type ApiTokenPresetGroups = Record<string, string[] | '*'>
|
||||
|
||||
export interface ApiTokenPreset {
|
||||
id: string
|
||||
groups: ApiTokenPresetGroups
|
||||
label?: string
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import AbstractModel from '@/models/abstractModel'
|
||||
import type {IApiToken, IApiPermission} from '@/modelTypes/IApiToken'
|
||||
|
||||
export default class ApiTokenModel extends AbstractModel<IApiToken> {
|
||||
id = 0
|
||||
title = ''
|
||||
token = ''
|
||||
permissions: IApiPermission = {}
|
||||
expiresAt: Date = new Date(0)
|
||||
created: Date = new Date(0)
|
||||
ownerId = 0
|
||||
|
||||
constructor(data: Partial<IApiToken> = {}) {
|
||||
super()
|
||||
|
||||
this.assignData(data)
|
||||
|
||||
this.expiresAt = new Date(this.expiresAt)
|
||||
this.created = new Date(this.created)
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import AbstractService from '@/services/abstractService'
|
||||
import type {IApiToken} from '@/modelTypes/IApiToken'
|
||||
import ApiTokenModel from '@/models/apiTokenModel'
|
||||
import {toISOStringOrNull} from '@/helpers/time/toISOStringOrNull'
|
||||
|
||||
export default class ApiTokenService extends AbstractService<IApiToken> {
|
||||
constructor() {
|
||||
super({
|
||||
create: '/tokens',
|
||||
getAll: '/tokens',
|
||||
delete: '/tokens/{id}',
|
||||
})
|
||||
}
|
||||
|
||||
processModel(model: IApiToken) {
|
||||
return {
|
||||
...model,
|
||||
expiresAt: toISOStringOrNull(model.expiresAt),
|
||||
created: toISOStringOrNull(model.created),
|
||||
}
|
||||
}
|
||||
|
||||
modelFactory(data: Partial<IApiToken>) {
|
||||
return new ApiTokenModel(data)
|
||||
}
|
||||
|
||||
async getAvailableRoutes() {
|
||||
const cancel = this.setLoading()
|
||||
|
||||
try {
|
||||
const response = await this.http.get('/routes')
|
||||
return response.data
|
||||
} finally {
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user