Finalize Typescript restructure

This commit is contained in:
Darko Gjorgjijoski
2026-04-06 17:59:15 +02:00
parent cab785172e
commit 74b4b2df4e
209 changed files with 12419 additions and 1745 deletions

View File

@@ -36,6 +36,11 @@ export interface RegisterWithInvitationPayload {
email: string
password: string
password_confirmation: string
invitation_token: string
}
export interface RegisterWithInvitationResponse {
type: string
token: string
}
@@ -74,8 +79,8 @@ export const authService = {
return data
},
async registerWithInvitation(payload: RegisterWithInvitationPayload): Promise<ApiResponse<User>> {
const { data } = await client.post(API.REGISTER_WITH_INVITATION, payload)
async registerWithInvitation(payload: RegisterWithInvitationPayload): Promise<RegisterWithInvitationResponse> {
const { data } = await client.post<RegisterWithInvitationResponse>(API.REGISTER_WITH_INVITATION, payload)
return data
},
}

View File

@@ -1,28 +1,35 @@
import { client } from '../client'
import { API } from '../endpoints'
import type { ApiResponse, ListParams } from '@v2/types/api'
export interface Backup {
id: number
disk: string
path: string
created_at: string
file_size: string
size: string
}
export interface BackupListResponse {
backups: Backup[]
disks: string[]
error?: string
error_message?: string
}
export interface CreateBackupPayload {
option: 'full' | 'database' | 'files'
selected_disk: string | null
option: 'full' | 'only-db' | 'only-files'
file_disk_id: number
}
export interface DeleteBackupParams {
disk: string
path?: string
file_name?: string
path: string
file_disk_id?: number
}
export const backupService = {
async list(params?: ListParams): Promise<ApiResponse<Backup[]>> {
async list(params: {
disk: string
file_disk_id?: number
}): Promise<BackupListResponse> {
const { data } = await client.get(API.BACKUPS, { params })
return data
},
@@ -37,7 +44,11 @@ export const backupService = {
return data
},
async download(params: { disk: string; path?: string; file_name?: string }): Promise<Blob> {
async download(params: {
disk: string
path: string
file_disk_id?: number
}): Promise<Blob> {
const { data } = await client.get(API.DOWNLOAD_BACKUP, {
params,
responseType: 'blob',

View File

@@ -8,9 +8,10 @@ import type { Ability } from '@v2/types/domain/role'
export interface MenuItem {
title: string
name: string
route: string
link: string
icon: string
group: string
group_label?: string
ability?: string
}
@@ -27,6 +28,7 @@ export interface BootstrapResponse {
config: Record<string, unknown>
global_settings: Record<string, string>
modules: string[]
admin_mode?: boolean
pending_invitations?: Array<{
token: string
company_name: string

View File

@@ -17,6 +17,7 @@ export interface CreateCustomFieldPayload {
is_required?: boolean
options?: Array<{ name: string }> | string[] | null
order?: number | null
default_answer?: string | null
}
export const customFieldService = {

View File

@@ -24,16 +24,28 @@ export interface CustomerListResponse {
meta: CustomerListMeta
}
export interface CustomerStatsData {
id: number
name: string
email: string | null
total_invoices: number
total_estimates: number
total_payments: number
total_expenses: number
total_amount_due: number
total_paid: number
export interface CustomerStatsChartData {
salesTotal: number
totalReceipts: number
totalExpenses: number
netProfit: number
expenseTotals: number[]
netProfits: number[]
months: string[]
receiptTotals: number[]
invoiceTotals: number[]
}
export interface CustomerStatsParams {
previous_year?: boolean
this_year?: boolean
}
export interface CustomerStatsResponse {
data: Customer
meta: {
chartData: CustomerStatsChartData
}
}
export const customerService = {
@@ -62,7 +74,10 @@ export const customerService = {
return data
},
async getStats(id: number, params?: Record<string, unknown>): Promise<ApiResponse<CustomerStatsData>> {
async getStats(
id: number,
params?: CustomerStatsParams
): Promise<CustomerStatsResponse> {
const { data } = await client.get(`${API.CUSTOMER_STATS}/${id}/stats`, { params })
return data
},

View File

@@ -1,54 +1,59 @@
import { client } from '../client'
import { API } from '../endpoints'
import type { ApiResponse, ListParams } from '@v2/types/api'
import type { ApiResponse, ListParams, PaginatedResponse } from '@v2/types/api'
export type DiskDriverValue =
| 'local'
| 's3'
| 's3compat'
| 'doSpaces'
| 'dropbox'
export interface Disk {
id: number
name: string
driver: string
type: string
driver: DiskDriverValue
set_as_default: boolean
credentials: Record<string, string>
created_at: string
updated_at: string
credentials: Record<string, string> | string | null
company_id?: number | null
}
export interface DiskDriversResponse {
drivers: string[]
[key: string]: unknown
drivers: Array<{
name: string
value: DiskDriverValue
}>
default: DiskDriverValue | string
}
export interface CreateDiskPayload {
name: string
selected_driver: string
// S3/S3-compat/DOSpaces fields
key?: string
secret?: string
region?: string
bucket?: string
root?: string
endpoint?: string
// Dropbox fields
token?: string
app?: string
driver: DiskDriverValue
credentials?: Record<string, string> | string
set_as_default?: boolean
}
export const diskService = {
async list(params?: ListParams): Promise<ApiResponse<Disk[]>> {
async list(params?: ListParams): Promise<PaginatedResponse<Disk>> {
const { data } = await client.get(API.DISKS, { params })
return data
},
async get(disk: string): Promise<Record<string, unknown>> {
async get(disk: DiskDriverValue): Promise<Record<string, string>> {
const { data } = await client.get(`${API.DISKS}/${disk}`)
return data
},
async create(payload: CreateDiskPayload): Promise<Disk> {
async create(payload: CreateDiskPayload): Promise<ApiResponse<Disk>> {
const { data } = await client.post(API.DISKS, payload)
return data
},
async update(id: number, payload: Partial<CreateDiskPayload>): Promise<ApiResponse<Disk>> {
async update(
id: number,
payload: Partial<CreateDiskPayload>
): Promise<ApiResponse<Disk>> {
const { data } = await client.put(`${API.DISKS}/${id}`, payload)
return data
},

View File

@@ -23,6 +23,7 @@ export { backupService } from './backup.service'
export { mailService } from './mail.service'
export { pdfService } from './pdf.service'
export { diskService } from './disk.service'
export { updateService } from './update.service'
// Re-export service types for convenience
export type { LoginPayload, LoginResponse, ForgotPasswordPayload, ResetPasswordPayload, RegisterWithInvitationPayload } from './auth.service'
@@ -30,7 +31,13 @@ export type { BootstrapResponse, MenuItem, CurrentCompanyResponse } from './boot
export type { InvoiceListParams, InvoiceListResponse, SendInvoicePayload, InvoiceStatusPayload, InvoiceTemplatesResponse } from './invoice.service'
export type { EstimateListParams, EstimateListResponse, SendEstimatePayload, EstimateStatusPayload, EstimateTemplatesResponse } from './estimate.service'
export type { RecurringInvoiceListParams, RecurringInvoiceListResponse, FrequencyDateParams, FrequencyDateResponse } from './recurring-invoice.service'
export type { CustomerListParams, CustomerListResponse, CustomerStatsData } from './customer.service'
export type {
CustomerListParams,
CustomerListResponse,
CustomerStatsChartData,
CustomerStatsParams,
CustomerStatsResponse,
} from './customer.service'
export type { PaymentListParams, PaymentListResponse, SendPaymentPayload, CreatePaymentMethodPayload } from './payment.service'
export type { ExpenseListParams, ExpenseListResponse, CreateExpenseCategoryPayload } from './expense.service'
export type { ItemListParams, ItemListResponse, CreateItemPayload, CreateUnitPayload } from './item.service'
@@ -46,7 +53,8 @@ export type { CustomFieldListParams, CreateCustomFieldPayload } from './custom-f
export type { CreateNotePayload } from './note.service'
export type { CreateExchangeRateProviderPayload, BulkUpdatePayload, ExchangeRateResponse, ActiveProviderResponse } from './exchange-rate.service'
export type { Module, ModuleInstallPayload, ModuleCheckResponse } from './module.service'
export type { Backup, CreateBackupPayload, DeleteBackupParams } from './backup.service'
export type { Backup, BackupListResponse, CreateBackupPayload, DeleteBackupParams } from './backup.service'
export type { MailConfig, MailConfigResponse, MailDriver, SmtpConfig, MailgunConfig, SesConfig, TestMailPayload } from './mail.service'
export type { PdfConfig, PdfConfigResponse, PdfDriver, DomPdfConfig, GotenbergConfig } from './pdf.service'
export type { Disk, DiskDriversResponse, CreateDiskPayload } from './disk.service'
export type { Disk, DiskDriversResponse, DiskDriverValue, CreateDiskPayload } from './disk.service'
export type { CheckUpdateResponse, UpdateRelease, UpdateDownloadResponse, UpdateStepResponse, FinishUpdatePayload } from './update.service'

View File

@@ -30,10 +30,12 @@ export interface InvoiceListResponse {
export interface SendInvoicePayload {
id: number
subject?: string
body?: string
from?: string
to?: string
subject?: string | null
body?: string | null
from?: string | null
to?: string | null
cc?: string | null
bcc?: string | null
}
export interface InvoiceStatusPayload {
@@ -43,6 +45,12 @@ export interface InvoiceStatusPayload {
export interface SendPreviewParams {
id: number
from?: string | null
to?: string | null
cc?: string | null
bcc?: string | null
subject?: string | null
body?: string | null
}
export interface InvoiceTemplate {

View File

@@ -1,10 +1,7 @@
import { client } from '../client'
import { API } from '../endpoints'
export interface MailDriver {
name: string
value: string
}
export type MailDriver = string
export interface SmtpConfig {
mail_driver: string
@@ -46,6 +43,8 @@ export interface MailConfigResponse {
export interface TestMailPayload {
to: string
subject: string
message: string
}
export const mailService = {

View File

@@ -31,7 +31,7 @@ export interface UpdateMemberPayload {
export interface InviteMemberPayload {
email: string
role?: string
role_id: number | null
}
export interface DeleteMembersPayload {

View File

@@ -1,10 +1,7 @@
import { client } from '../client'
import { API } from '../endpoints'
export interface PdfDriver {
name: string
value: string
}
export type PdfDriver = string
export interface DomPdfConfig {
pdf_driver: string

View File

@@ -28,7 +28,7 @@ export interface NumberPlaceholdersParams {
}
export interface NumberPlaceholder {
description: string
name: string
value: string
}
@@ -102,7 +102,7 @@ export const settingService = {
},
// App Version
async getAppVersion(): Promise<{ version: string }> {
async getAppVersion(): Promise<{ version: string; channel: string }> {
const { data } = await client.get(API.APP_VERSION)
return data
},

View File

@@ -0,0 +1,74 @@
import { client } from '../client'
import { API } from '../endpoints'
export interface UpdateRelease {
version: string
description?: string | null
changelog?: string | null
extensions?: Record<string, boolean>
min_php_version?: string | null
deleted_files?: string | string[] | null
}
export interface CheckUpdateResponse {
success?: boolean
release: UpdateRelease | null
is_minor?: boolean
}
export interface UpdateDownloadResponse {
success: boolean
path?: string | boolean | Record<string, unknown> | null
}
export interface UpdateStepResponse {
success: boolean
path?: string | boolean | Record<string, unknown> | null
error?: string | boolean
data?: Record<string, unknown>
}
export interface FinishUpdatePayload {
installed: string
version: string
}
export const updateService = {
async check(channel: 'stable' | 'insider' = 'stable'): Promise<CheckUpdateResponse> {
const { data } = await client.get(API.CHECK_UPDATE, {
params: { channel },
})
return data
},
async download(payload: { version: string }): Promise<UpdateDownloadResponse> {
const { data } = await client.post(API.UPDATE_DOWNLOAD, payload)
return data
},
async unzip(payload: { path: string }): Promise<UpdateStepResponse> {
const { data } = await client.post(API.UPDATE_UNZIP, payload)
return data
},
async copy(payload: { path: string }): Promise<UpdateStepResponse> {
const { data } = await client.post(API.UPDATE_COPY, payload)
return data
},
async delete(payload: { deleted_files?: string | string[] | null }): Promise<UpdateStepResponse> {
const { data } = await client.post(API.UPDATE_DELETE, payload)
return data
},
async migrate(): Promise<UpdateStepResponse> {
const { data } = await client.post(API.UPDATE_MIGRATE)
return data
},
async finish(payload: FinishUpdatePayload): Promise<UpdateStepResponse> {
const { data } = await client.post(API.UPDATE_FINISH, payload)
return data
},
}