feat(sdk): add OpenAPI export script and TypeScript SDK package
- Add export-openapi.ts script for server OpenAPI spec export - Add shared/sdk-ts package with generated API clients (accounts, bills, customers, vendors, etc.) - Update Customers and Vendors controllers - Update ReportsEventsTracker - Update .gitignore, package.json, and pnpm-lock Made-with: Cursor
This commit is contained in:
@@ -8,3 +8,6 @@ node_modules/
|
|||||||
|
|
||||||
test-results/
|
test-results/
|
||||||
.qodo
|
.qodo
|
||||||
|
|
||||||
|
|
||||||
|
.pnpm-store
|
||||||
+2
-1
@@ -22,7 +22,8 @@
|
|||||||
"system:migrate:latest": "lerna run cli:system:migrate:latest --scope \"@bigcapital/server\"",
|
"system:migrate:latest": "lerna run cli:system:migrate:latest --scope \"@bigcapital/server\"",
|
||||||
"tenants:migrate:latest": "lerna run cli:tenants:migrate:latest --scope \"@bigcapital/server\"",
|
"tenants:migrate:latest": "lerna run cli:tenants:migrate:latest --scope \"@bigcapital/server\"",
|
||||||
"system:seed:latest": "lerna run cli:system:seed:latest --scope \"@bigcapital/server\"",
|
"system:seed:latest": "lerna run cli:system:seed:latest --scope \"@bigcapital/server\"",
|
||||||
"tenants:seed:latest": "lerna run cli:tenants:seed:latest --scope \"@bigcapital/server\""
|
"tenants:seed:latest": "lerna run cli:tenants:seed:latest --scope \"@bigcapital/server\"",
|
||||||
|
"generate:sdk-types": "lerna run openapi:export --scope \"@bigcapital/server\" && lerna run generate --scope \"@bigcapital/sdk-ts\" && lerna run build --scope \"@bigcapital/sdk-ts\""
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^17.4.2",
|
"@commitlint/cli": "^17.4.2",
|
||||||
|
|||||||
@@ -27,15 +27,17 @@
|
|||||||
"cli:tenants:migrate:rollback": "ts-node -r tsconfig-paths/register src/cli.ts tenants:migrate:rollback",
|
"cli:tenants:migrate:rollback": "ts-node -r tsconfig-paths/register src/cli.ts tenants:migrate:rollback",
|
||||||
"cli:tenants:migrate:make": "ts-node -r tsconfig-paths/register src/cli.ts tenants:migrate:make",
|
"cli:tenants:migrate:make": "ts-node -r tsconfig-paths/register src/cli.ts tenants:migrate:make",
|
||||||
"cli:tenants:list": "ts-node -r tsconfig-paths/register src/cli.ts tenants:list",
|
"cli:tenants:list": "ts-node -r tsconfig-paths/register src/cli.ts tenants:list",
|
||||||
|
"openapi:export": "ts-node -r tsconfig-paths/register scripts/export-openapi.ts",
|
||||||
"cli:system:seed:latest": "ts-node -r tsconfig-paths/register src/cli.ts system:seed:latest",
|
"cli:system:seed:latest": "ts-node -r tsconfig-paths/register src/cli.ts system:seed:latest",
|
||||||
"cli:tenants:seed:latest": "ts-node -r tsconfig-paths/register src/cli.ts tenants:seed:latest"
|
"cli:tenants:seed:latest": "ts-node -r tsconfig-paths/register src/cli.ts tenants:seed:latest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.576.0",
|
"@aws-sdk/client-s3": "^3.576.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.583.0",
|
"@aws-sdk/s3-request-presigner": "^3.583.0",
|
||||||
"@bigcapital/email-components": "*",
|
"@bigcapital/email-components": "workspace:*",
|
||||||
"@bigcapital/pdf-templates": "*",
|
"@bigcapital/pdf-templates": "workspace:*",
|
||||||
"@bigcapital/utils": "*",
|
"@bigcapital/sdk-ts": "workspace:*",
|
||||||
|
"@bigcapital/utils": "workspace:*",
|
||||||
"@casl/ability": "^5.4.3",
|
"@casl/ability": "^5.4.3",
|
||||||
"@lemonsqueezy/lemonsqueezy.js": "^2.2.0",
|
"@lemonsqueezy/lemonsqueezy.js": "^2.2.0",
|
||||||
"@liaoliaots/nestjs-redis": "^10.0.0",
|
"@liaoliaots/nestjs-redis": "^10.0.0",
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* Exports the OpenAPI document from the NestJS app to shared/sdk-ts/openapi.json.
|
||||||
|
* Run from packages/server: pnpm run openapi:export
|
||||||
|
*/
|
||||||
|
/// <reference path="../src/common/types/Objection.d.ts" />
|
||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||||
|
import { ClsMiddleware } from 'nestjs-cls';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import '@/utils/moment-mysql';
|
||||||
|
import { AppModule } from '@/modules/App/App.module';
|
||||||
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||||
|
|
||||||
|
async function exportOpenApi() {
|
||||||
|
global.__public_dirname = path.join(__dirname, '..', 'public');
|
||||||
|
global.__static_dirname = path.join(__dirname, '..', 'static');
|
||||||
|
global.__views_dirname = path.join(global.__static_dirname, '/views');
|
||||||
|
global.__images_dirname = path.join(global.__static_dirname, '/images');
|
||||||
|
|
||||||
|
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
||||||
|
rawBody: true,
|
||||||
|
});
|
||||||
|
app.set('query parser', 'extended');
|
||||||
|
app.setGlobalPrefix('/api');
|
||||||
|
app.use(new ClsMiddleware({}).use);
|
||||||
|
|
||||||
|
const config = new DocumentBuilder()
|
||||||
|
.setTitle('Bigcapital')
|
||||||
|
.setDescription('Financial accounting software')
|
||||||
|
.setVersion('1.0')
|
||||||
|
.build();
|
||||||
|
|
||||||
|
const document = SwaggerModule.createDocument(app, config);
|
||||||
|
await app.close();
|
||||||
|
|
||||||
|
const outputPath = path.resolve(__dirname, '../../../shared/sdk-ts/openapi.json');
|
||||||
|
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
||||||
|
fs.writeFileSync(outputPath, JSON.stringify(document, null, 2), 'utf-8');
|
||||||
|
console.log(`OpenAPI spec written to ${outputPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
exportOpenApi().catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -36,6 +36,7 @@ import { CustomerAction } from './types/Customers.types';
|
|||||||
@Controller('customers')
|
@Controller('customers')
|
||||||
@ApiTags('Customers')
|
@ApiTags('Customers')
|
||||||
@ApiExtraModels(CustomerResponseDto)
|
@ApiExtraModels(CustomerResponseDto)
|
||||||
|
@ApiExtraModels(ValidateBulkDeleteCustomersResponseDto)
|
||||||
@ApiCommonHeaders()
|
@ApiCommonHeaders()
|
||||||
@UseGuards(AuthorizationGuard, PermissionGuard)
|
@UseGuards(AuthorizationGuard, PermissionGuard)
|
||||||
export class CustomersController {
|
export class CustomersController {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export class ReportsEventsTracker {
|
|||||||
constructor(private readonly posthog: EventTrackerService) {}
|
constructor(private readonly posthog: EventTrackerService) {}
|
||||||
|
|
||||||
@OnEvent(events.reports.onBalanceSheetViewed)
|
@OnEvent(events.reports.onBalanceSheetViewed)
|
||||||
handleTrackBalanceSheetViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackBalanceSheetViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: BALANCE_SHEET_VIEWED,
|
event: BALANCE_SHEET_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -33,7 +33,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onTrialBalanceSheetView)
|
@OnEvent(events.reports.onTrialBalanceSheetView)
|
||||||
handleTrackTrialBalanceSheetViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackTrialBalanceSheetViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: TRIAL_BALANCE_SHEET_VIEWED,
|
event: TRIAL_BALANCE_SHEET_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -41,7 +41,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onProfitLossSheetViewed)
|
@OnEvent(events.reports.onProfitLossSheetViewed)
|
||||||
handleTrackProfitLossSheetViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackProfitLossSheetViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: PROFIT_LOSS_SHEET_VIEWED,
|
event: PROFIT_LOSS_SHEET_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -49,7 +49,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onCashflowStatementViewed)
|
@OnEvent(events.reports.onCashflowStatementViewed)
|
||||||
handleTrackCashflowStatementViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackCashflowStatementViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: CASHFLOW_STATEMENT_VIEWED,
|
event: CASHFLOW_STATEMENT_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -57,7 +57,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onGeneralLedgerViewed)
|
@OnEvent(events.reports.onGeneralLedgerViewed)
|
||||||
handleTrackGeneralLedgerViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackGeneralLedgerViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: GENERAL_LEDGER_VIEWED,
|
event: GENERAL_LEDGER_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -65,7 +65,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onJournalViewed)
|
@OnEvent(events.reports.onJournalViewed)
|
||||||
handleTrackJournalViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackJournalViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: JOURNAL_VIEWED,
|
event: JOURNAL_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -73,7 +73,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onReceivableAgingViewed)
|
@OnEvent(events.reports.onReceivableAgingViewed)
|
||||||
handleTrackReceivableAgingViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackReceivableAgingViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: RECEIVABLE_AGING_VIEWED,
|
event: RECEIVABLE_AGING_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -81,7 +81,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onPayableAgingViewed)
|
@OnEvent(events.reports.onPayableAgingViewed)
|
||||||
handleTrackPayableAgingViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackPayableAgingViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: PAYABLE_AGING_VIEWED,
|
event: PAYABLE_AGING_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -89,7 +89,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onCustomerBalanceSummaryViewed)
|
@OnEvent(events.reports.onCustomerBalanceSummaryViewed)
|
||||||
handleTrackCustomerBalanceSummaryViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackCustomerBalanceSummaryViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: CUSTOMER_BALANCE_SUMMARY_VIEWED,
|
event: CUSTOMER_BALANCE_SUMMARY_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -97,7 +97,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onVendorBalanceSummaryViewed)
|
@OnEvent(events.reports.onVendorBalanceSummaryViewed)
|
||||||
handleTrackVendorBalanceSummaryViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackVendorBalanceSummaryViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: VENDOR_BALANCE_SUMMARY_VIEWED,
|
event: VENDOR_BALANCE_SUMMARY_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -105,7 +105,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onInventoryValuationViewed)
|
@OnEvent(events.reports.onInventoryValuationViewed)
|
||||||
handleTrackInventoryValuationViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackInventoryValuationViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: INVENTORY_VALUATION_VIEWED,
|
event: INVENTORY_VALUATION_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -113,7 +113,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onCustomerTransactionsViewed)
|
@OnEvent(events.reports.onCustomerTransactionsViewed)
|
||||||
handleTrackCustomerTransactionsViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackCustomerTransactionsViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: CUSTOMER_TRANSACTIONS_VIEWED,
|
event: CUSTOMER_TRANSACTIONS_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -121,7 +121,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onVendorTransactionsViewed)
|
@OnEvent(events.reports.onVendorTransactionsViewed)
|
||||||
handleTrackVendorTransactionsViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackVendorTransactionsViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: VENDOR_TRANSACTIONS_VIEWED,
|
event: VENDOR_TRANSACTIONS_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -129,7 +129,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onSalesByItemViewed)
|
@OnEvent(events.reports.onSalesByItemViewed)
|
||||||
handleTrackSalesByItemViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackSalesByItemViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: SALES_BY_ITEM_VIEWED,
|
event: SALES_BY_ITEM_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -137,7 +137,7 @@ export class ReportsEventsTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(events.reports.onPurchasesByItemViewed)
|
@OnEvent(events.reports.onPurchasesByItemViewed)
|
||||||
handleTrackPurchasesByItemViewedEvent({ tenantId }: ReportsEvents) {
|
handleTrackPurchasesByItemViewedEvent() {
|
||||||
this.posthog.trackEvent({
|
this.posthog.trackEvent({
|
||||||
event: PURCHASES_BY_ITEM_VIEWED,
|
event: PURCHASES_BY_ITEM_VIEWED,
|
||||||
properties: {},
|
properties: {},
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
import { VendorsApplication } from './VendorsApplication.service';
|
import { VendorsApplication } from './VendorsApplication.service';
|
||||||
import { VendorOpeningBalanceEditDto } from './dtos/VendorOpeningBalanceEdit.dto';
|
import { VendorOpeningBalanceEditDto } from './dtos/VendorOpeningBalanceEdit.dto';
|
||||||
import {
|
import {
|
||||||
|
ApiExtraModels,
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
ApiResponse,
|
ApiResponse,
|
||||||
ApiTags,
|
ApiTags,
|
||||||
@@ -33,6 +34,7 @@ import { VendorAction } from '../Customers/types/Customers.types';
|
|||||||
|
|
||||||
@Controller('vendors')
|
@Controller('vendors')
|
||||||
@ApiTags('Vendors')
|
@ApiTags('Vendors')
|
||||||
|
@ApiExtraModels(ValidateBulkDeleteVendorsResponseDto)
|
||||||
@ApiCommonHeaders()
|
@ApiCommonHeaders()
|
||||||
@UseGuards(AuthorizationGuard, PermissionGuard)
|
@UseGuards(AuthorizationGuard, PermissionGuard)
|
||||||
export class VendorsController {
|
export class VendorsController {
|
||||||
|
|||||||
Generated
+16512
-13258
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
/dist
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "@bigcapital/sdk-ts",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "TypeScript types generated from the Bigcapital API OpenAPI/Swagger spec",
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"require": "./dist/index.js",
|
||||||
|
"import": "./dist/index.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"generate": "node -e \"if(!require('fs').existsSync('./openapi.json')){console.error('\\n openapi.json not found. Run from repo root: pnpm run generate:sdk-types\\n'); process.exit(1)}\" && npx openapi-typescript ./openapi.json -o ./src/schema.ts",
|
||||||
|
"build:cjs": "tsup src/index.ts --format cjs --dts --sourcemap",
|
||||||
|
"build:esm": "tsup src/index.ts --format esm --dts --sourcemap",
|
||||||
|
"build": "npm run build:cjs && npm run build:esm",
|
||||||
|
"dev": "npm run build -- --watch"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"openapi-typescript-fetch": "^2.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"openapi-typescript": "^7.0.0",
|
||||||
|
"tsup": "^8.3.0",
|
||||||
|
"typescript": "^5.1.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const ACCOUNTS_ROUTES = {
|
||||||
|
LIST: '/api/accounts',
|
||||||
|
BY_ID: '/api/accounts/{id}',
|
||||||
|
TYPES: '/api/accounts/types',
|
||||||
|
TRANSACTIONS: '/api/accounts/transactions',
|
||||||
|
BULK_DELETE: '/api/accounts/bulk-delete',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/accounts/validate-bulk-delete',
|
||||||
|
ACTIVATE: '/api/accounts/{id}/activate',
|
||||||
|
INACTIVATE: '/api/accounts/{id}/inactivate',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetAccounts = paths[typeof ACCOUNTS_ROUTES.LIST]['get'];
|
||||||
|
type GetAccount = paths[typeof ACCOUNTS_ROUTES.BY_ID]['get'];
|
||||||
|
type GetAccountTypes = paths[typeof ACCOUNTS_ROUTES.TYPES]['get'];
|
||||||
|
type GetAccountTransactions = paths[typeof ACCOUNTS_ROUTES.TRANSACTIONS]['get'];
|
||||||
|
type CreateAccount = paths[typeof ACCOUNTS_ROUTES.LIST]['post'];
|
||||||
|
type EditAccount = paths[typeof ACCOUNTS_ROUTES.BY_ID]['put'];
|
||||||
|
type BulkDeleteAccounts = paths[typeof ACCOUNTS_ROUTES.BULK_DELETE]['post'];
|
||||||
|
type ValidateBulkDelete = paths[typeof ACCOUNTS_ROUTES.VALIDATE_BULK_DELETE]['post'];
|
||||||
|
|
||||||
|
export type AccountsList = GetAccounts['responses'][200]['content']['application/json'];
|
||||||
|
export type Account = GetAccount['responses'][200]['content']['application/json'];
|
||||||
|
export type AccountTypesList = GetAccountTypes['responses'][200]['content']['application/json'];
|
||||||
|
export type AccountTransactionsList = GetAccountTransactions['responses'][200]['content']['application/json'];
|
||||||
|
export type CreateAccountBody = CreateAccount['requestBody']['content']['application/json'];
|
||||||
|
export type EditAccountBody = EditAccount['requestBody']['content']['application/json'];
|
||||||
|
export type BulkDeleteBody = BulkDeleteAccounts['requestBody']['content']['application/json'];
|
||||||
|
export type ValidateBulkDeleteResponse = ValidateBulkDelete['responses'][200]['content']['application/json'];
|
||||||
|
export type GetAccountsQuery = NonNullable<GetAccounts['parameters']['query']>;
|
||||||
|
|
||||||
|
function normalizeAccountsResponse(
|
||||||
|
data: AccountsList | { accounts: AccountsList }
|
||||||
|
): AccountsList {
|
||||||
|
return Array.isArray(data) ? data : data.accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchAccounts(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
query: GetAccountsQuery
|
||||||
|
): Promise<AccountsList> {
|
||||||
|
const getAccounts = fetcher.path(ACCOUNTS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await getAccounts(query ?? {});
|
||||||
|
return normalizeAccountsResponse(data as AccountsList | { accounts: AccountsList });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchAccount(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number
|
||||||
|
): Promise<Account> {
|
||||||
|
const getAccount = fetcher.path(ACCOUNTS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await getAccount({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchAccountTypes(
|
||||||
|
fetcher: ApiFetcher
|
||||||
|
): Promise<AccountTypesList> {
|
||||||
|
const getAccountTypes = fetcher.path(ACCOUNTS_ROUTES.TYPES).method('get').create();
|
||||||
|
const { data } = await getAccountTypes({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchAccountTransactions(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number
|
||||||
|
): Promise<AccountTransactionsList> {
|
||||||
|
const getAccountTransactions = fetcher.path(ACCOUNTS_ROUTES.TRANSACTIONS).method('get').create();
|
||||||
|
const { data } = await getAccountTransactions({ accountId: id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createAccount(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateAccountBody
|
||||||
|
): Promise<void> {
|
||||||
|
const create = fetcher.path(ACCOUNTS_ROUTES.LIST).method('post').create();
|
||||||
|
await create(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editAccount(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditAccountBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(ACCOUNTS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteAccount(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number
|
||||||
|
): Promise<void> {
|
||||||
|
const del = fetcher.path(ACCOUNTS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activateAccount(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number
|
||||||
|
): Promise<void> {
|
||||||
|
const activate = fetcher.path(ACCOUNTS_ROUTES.ACTIVATE).method('post').create();
|
||||||
|
await activate({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function inactivateAccount(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number
|
||||||
|
): Promise<void> {
|
||||||
|
const inactivate = fetcher.path(ACCOUNTS_ROUTES.INACTIVATE).method('post').create();
|
||||||
|
await inactivate({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function bulkDeleteAccounts(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: BulkDeleteBody
|
||||||
|
): Promise<void> {
|
||||||
|
const bulkDelete = fetcher.path(ACCOUNTS_ROUTES.BULK_DELETE).method('post').create();
|
||||||
|
await bulkDelete(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function validateBulkDeleteAccounts(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
ids: number[]
|
||||||
|
): Promise<ValidateBulkDeleteResponse> {
|
||||||
|
const validate = fetcher.path(ACCOUNTS_ROUTES.VALIDATE_BULK_DELETE).method('post').create();
|
||||||
|
const { data } = await validate({ ids, skipUndeletable: false });
|
||||||
|
return data as ValidateBulkDeleteResponse;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const API_KEYS_ROUTES = {
|
||||||
|
LIST: '/api/api-keys',
|
||||||
|
GENERATE: '/api/api-keys/generate',
|
||||||
|
REVOKE: '/api/api-keys/{id}/revoke',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetApiKeys = paths[typeof API_KEYS_ROUTES.LIST]['get'];
|
||||||
|
type GenerateApiKey = paths[typeof API_KEYS_ROUTES.GENERATE]['post'];
|
||||||
|
type RevokeApiKey = paths[typeof API_KEYS_ROUTES.REVOKE]['put'];
|
||||||
|
|
||||||
|
export type ApiKeysList = GetApiKeys['responses'][200]['content']['application/json'];
|
||||||
|
export type GenerateApiKeyBody = GenerateApiKey['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchApiKeys(fetcher: ApiFetcher): Promise<ApiKeysList> {
|
||||||
|
const get = fetcher.path(API_KEYS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generateApiKey(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: GenerateApiKeyBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(API_KEYS_ROUTES.GENERATE).method('post').create();
|
||||||
|
await post(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function revokeApiKey(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const put = fetcher.path(API_KEYS_ROUTES.REVOKE).method('put').create();
|
||||||
|
await put({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const AUTH_ROUTES = {
|
||||||
|
ACCOUNT: '/api/auth/account',
|
||||||
|
RESEND_SIGNUP: '/api/auth/signup/verify/resend',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetAuthedAccount = paths[typeof AUTH_ROUTES.ACCOUNT]['get'];
|
||||||
|
|
||||||
|
type GetAuthedAccount200 = GetAuthedAccount['responses'][200];
|
||||||
|
export type AuthedAccount = GetAuthedAccount200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchAuthedAccount(fetcher: ApiFetcher): Promise<AuthedAccount> {
|
||||||
|
const get = fetcher.path(AUTH_ROUTES.ACCOUNT).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const BILLS_ROUTES = {
|
||||||
|
LIST: '/api/bills',
|
||||||
|
BY_ID: '/api/bills/{id}',
|
||||||
|
PAYMENT_TRANSACTIONS: '/api/bills/{id}/payment-transactions',
|
||||||
|
OPEN: '/api/bills/{id}/open',
|
||||||
|
DUE: '/api/bills/due',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/bills/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/bills/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetBills = paths[typeof BILLS_ROUTES.LIST]['get'];
|
||||||
|
type GetBill = paths[typeof BILLS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateBill = paths[typeof BILLS_ROUTES.LIST]['post'];
|
||||||
|
type EditBill = paths[typeof BILLS_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteBill = paths[typeof BILLS_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
export type BillsListResponse = GetBills['responses'][200]['content']['application/json'];
|
||||||
|
export type Bill = GetBill['responses'][200]['content']['application/json'];
|
||||||
|
export type CreateBillBody = CreateBill['requestBody']['content']['application/json'];
|
||||||
|
export type EditBillBody = EditBill['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchBills(fetcher: ApiFetcher): Promise<BillsListResponse> {
|
||||||
|
const get = fetcher.path(BILLS_ROUTES.LIST).method('get').create();
|
||||||
|
// Schema incorrectly marks path.id on list endpoint; route has no {id}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const { data } = await (get as (params?: any) => Promise<{ data: BillsListResponse }>)({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchBill(fetcher: ApiFetcher, id: number): Promise<Bill> {
|
||||||
|
const get = fetcher.path(BILLS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createBill(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateBillBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(BILLS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editBill(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditBillBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(BILLS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteBill(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(BILLS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const BRANCHES_ROUTES = {
|
||||||
|
LIST: '/api/branches',
|
||||||
|
BY_ID: '/api/branches/{id}',
|
||||||
|
ACTIVATE: '/api/branches/activate',
|
||||||
|
MARK_AS_PRIMARY: '/api/branches/{id}/mark-as-primary',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetBranches = paths[typeof BRANCHES_ROUTES.LIST]['get'];
|
||||||
|
type GetBranch = paths[typeof BRANCHES_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateBranch = paths[typeof BRANCHES_ROUTES.LIST]['post'];
|
||||||
|
type EditBranch = paths[typeof BRANCHES_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteBranch = paths[typeof BRANCHES_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
export type BranchesListResponse = GetBranches['responses'][200]['content']['application/json'];
|
||||||
|
export type Branch = GetBranch['responses'][200]['content']['application/json'];
|
||||||
|
export type CreateBranchBody = CreateBranch['requestBody']['content']['application/json'];
|
||||||
|
export type EditBranchBody = EditBranch['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchBranches(fetcher: ApiFetcher): Promise<BranchesListResponse> {
|
||||||
|
const get = fetcher.path(BRANCHES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchBranch(fetcher: ApiFetcher, id: string): Promise<Branch> {
|
||||||
|
const get = fetcher.path(BRANCHES_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createBranch(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateBranchBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(BRANCHES_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editBranch(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: string,
|
||||||
|
values: EditBranchBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(BRANCHES_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteBranch(fetcher: ApiFetcher, id: string): Promise<void> {
|
||||||
|
const del = fetcher.path(BRANCHES_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activateBranches(fetcher: ApiFetcher): Promise<void> {
|
||||||
|
const post = fetcher.path(BRANCHES_ROUTES.ACTIVATE).method('post').create();
|
||||||
|
await post({});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function markBranchAsPrimary(fetcher: ApiFetcher, id: string): Promise<void> {
|
||||||
|
const put = fetcher.path(BRANCHES_ROUTES.MARK_AS_PRIMARY).method('put').create();
|
||||||
|
await put({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const BANKING_ACCOUNTS_ROUTES = {
|
||||||
|
LIST: '/api/banking/accounts',
|
||||||
|
SUMMARY: '/api/banking/accounts/{bankAccountId}/summary',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetBankingAccounts = paths[typeof BANKING_ACCOUNTS_ROUTES.LIST]['get'];
|
||||||
|
|
||||||
|
type GetBankingAccounts200 = GetBankingAccounts['responses'][200];
|
||||||
|
export type BankingAccountsListResponse = GetBankingAccounts200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchBankingAccounts(fetcher: ApiFetcher): Promise<BankingAccountsListResponse> {
|
||||||
|
const get = fetcher.path(BANKING_ACCOUNTS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchBankingAccountSummary(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
bankAccountId: number
|
||||||
|
): Promise<void> {
|
||||||
|
const get = fetcher.path(BANKING_ACCOUNTS_ROUTES.SUMMARY).method('get').create();
|
||||||
|
await get({ bankAccountId });
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const CONTACTS_ROUTES = {
|
||||||
|
AUTO_COMPLETE: '/api/contacts/auto-complete',
|
||||||
|
ACTIVATE: '/api/contacts/{id}/activate',
|
||||||
|
INACTIVATE: '/api/contacts/{id}/inactivate',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type AutoComplete = paths[typeof CONTACTS_ROUTES.AUTO_COMPLETE]['get'];
|
||||||
|
|
||||||
|
type AutoComplete200 = AutoComplete['responses'][200];
|
||||||
|
export type ContactsAutoCompleteResponse = AutoComplete200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchContactsAutoComplete(fetcher: ApiFetcher): Promise<ContactsAutoCompleteResponse> {
|
||||||
|
const get = fetcher.path(CONTACTS_ROUTES.AUTO_COMPLETE).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activateContact(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const patch = fetcher.path(CONTACTS_ROUTES.ACTIVATE).method('patch').create();
|
||||||
|
await patch({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function inactivateContact(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const patch = fetcher.path(CONTACTS_ROUTES.INACTIVATE).method('patch').create();
|
||||||
|
await patch({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const CREDIT_NOTES_ROUTES = {
|
||||||
|
LIST: '/api/credit-notes',
|
||||||
|
BY_ID: '/api/credit-notes/{id}',
|
||||||
|
STATE: '/api/credit-notes/state',
|
||||||
|
OPEN: '/api/credit-notes/{id}/open',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/credit-notes/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/credit-notes/bulk-delete',
|
||||||
|
REFUNDS: '/api/credit-notes/{creditNoteId}/refunds',
|
||||||
|
REFUND_BY_ID: '/api/credit-notes/refunds/{refundCreditId}',
|
||||||
|
APPLIED_INVOICES: '/api/credit-notes/{creditNoteId}/applied-invoices',
|
||||||
|
APPLY_INVOICES: '/api/credit-notes/{creditNoteId}/apply-invoices',
|
||||||
|
APPLIED_INVOICE_BY_ID: '/api/credit-notes/applied-invoices/{applyCreditToInvoicesId}',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetCreditNotes = paths[typeof CREDIT_NOTES_ROUTES.LIST]['get'];
|
||||||
|
type GetCreditNote = paths[typeof CREDIT_NOTES_ROUTES.BY_ID]['get'];
|
||||||
|
type GetCreditNoteState = paths[typeof CREDIT_NOTES_ROUTES.STATE]['get'];
|
||||||
|
type CreateCreditNote = paths[typeof CREDIT_NOTES_ROUTES.LIST]['post'];
|
||||||
|
type EditCreditNote = paths[typeof CREDIT_NOTES_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteCreditNote = paths[typeof CREDIT_NOTES_ROUTES.BY_ID]['delete'];
|
||||||
|
type OpenCreditNote = paths[typeof CREDIT_NOTES_ROUTES.OPEN]['put'];
|
||||||
|
type ValidateBulkDeleteCreditNotes = paths[typeof CREDIT_NOTES_ROUTES.VALIDATE_BULK_DELETE]['post'];
|
||||||
|
type BulkDeleteCreditNotes = paths[typeof CREDIT_NOTES_ROUTES.BULK_DELETE]['post'];
|
||||||
|
type GetCreditNoteRefunds = paths[typeof CREDIT_NOTES_ROUTES.REFUNDS]['get'];
|
||||||
|
type CreateRefundCreditNote = paths[typeof CREDIT_NOTES_ROUTES.REFUNDS]['post'];
|
||||||
|
type DeleteRefundCreditNote = paths[typeof CREDIT_NOTES_ROUTES.REFUND_BY_ID]['delete'];
|
||||||
|
type GetAppliedInvoices = paths[typeof CREDIT_NOTES_ROUTES.APPLIED_INVOICES]['get'];
|
||||||
|
type GetApplyInvoices = paths[typeof CREDIT_NOTES_ROUTES.APPLY_INVOICES]['get'];
|
||||||
|
type ApplyCreditNoteToInvoices = paths[typeof CREDIT_NOTES_ROUTES.APPLY_INVOICES]['post'];
|
||||||
|
type DeleteApplyCreditNoteToInvoices = paths[typeof CREDIT_NOTES_ROUTES.APPLIED_INVOICE_BY_ID]['delete'];
|
||||||
|
|
||||||
|
export type CreditNotesListResponse = GetCreditNotes['responses'][200]['content']['application/json'];
|
||||||
|
export type CreditNote = GetCreditNote['responses'][200]['content']['application/json'];
|
||||||
|
export type CreateCreditNoteBody = CreateCreditNote['requestBody']['content']['application/json'];
|
||||||
|
export type EditCreditNoteBody = EditCreditNote['requestBody']['content']['application/json'];
|
||||||
|
export type ValidateBulkDeleteCreditNotesBody = ValidateBulkDeleteCreditNotes['requestBody']['content']['application/json'];
|
||||||
|
export type ValidateBulkDeleteCreditNotesResponse = ValidateBulkDeleteCreditNotes['responses'][200]['content']['application/json'];
|
||||||
|
export type BulkDeleteCreditNotesBody = BulkDeleteCreditNotes['requestBody']['content']['application/json'];
|
||||||
|
export type CreateRefundCreditNoteBody = CreateRefundCreditNote['requestBody']['content']['application/json'];
|
||||||
|
export type ApplyCreditNoteToInvoicesBody = ApplyCreditNoteToInvoices['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchCreditNotes(fetcher: ApiFetcher): Promise<CreditNotesListResponse> {
|
||||||
|
const getCreditNotes = fetcher.path(CREDIT_NOTES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await getCreditNotes({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchCreditNote(fetcher: ApiFetcher, id: number): Promise<CreditNote> {
|
||||||
|
const getCreditNote = fetcher.path(CREDIT_NOTES_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await getCreditNote({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchCreditNoteState(fetcher: ApiFetcher): Promise<void> {
|
||||||
|
const getState = fetcher.path(CREDIT_NOTES_ROUTES.STATE).method('get').create();
|
||||||
|
await getState({});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createCreditNote(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateCreditNoteBody
|
||||||
|
): Promise<void> {
|
||||||
|
const create = fetcher.path(CREDIT_NOTES_ROUTES.LIST).method('post').create();
|
||||||
|
await create(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editCreditNote(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditCreditNoteBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(CREDIT_NOTES_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteCreditNote(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(CREDIT_NOTES_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function openCreditNote(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const open = fetcher.path(CREDIT_NOTES_ROUTES.OPEN).method('put').create();
|
||||||
|
await open({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function validateBulkDeleteCreditNotes(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: ValidateBulkDeleteCreditNotesBody
|
||||||
|
): Promise<ValidateBulkDeleteCreditNotesResponse> {
|
||||||
|
const validate = fetcher.path(CREDIT_NOTES_ROUTES.VALIDATE_BULK_DELETE).method('post').create();
|
||||||
|
const { data } = await validate(body);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function bulkDeleteCreditNotes(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: BulkDeleteCreditNotesBody
|
||||||
|
): Promise<void> {
|
||||||
|
const bulkDelete = fetcher.path(CREDIT_NOTES_ROUTES.BULK_DELETE).method('post').create();
|
||||||
|
await bulkDelete(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchCreditNoteRefunds(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
creditNoteId: number
|
||||||
|
): Promise<void> {
|
||||||
|
const getRefunds = fetcher.path(CREDIT_NOTES_ROUTES.REFUNDS).method('get').create();
|
||||||
|
await getRefunds({ creditNoteId });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createRefundCreditNote(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
creditNoteId: number,
|
||||||
|
values: CreateRefundCreditNoteBody
|
||||||
|
): Promise<void> {
|
||||||
|
const create = fetcher.path(CREDIT_NOTES_ROUTES.REFUNDS).method('post').create();
|
||||||
|
await create({ creditNoteId, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteRefundCreditNote(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
refundCreditId: number
|
||||||
|
): Promise<void> {
|
||||||
|
const del = fetcher.path(CREDIT_NOTES_ROUTES.REFUND_BY_ID).method('delete').create();
|
||||||
|
await del({ refundCreditId });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchAppliedInvoices(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
creditNoteId: number
|
||||||
|
): Promise<void> {
|
||||||
|
const getApplied = fetcher.path(CREDIT_NOTES_ROUTES.APPLIED_INVOICES).method('get').create();
|
||||||
|
await getApplied({ creditNoteId });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchCreditNoteAssociatedInvoicesToApply(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
creditNoteId: number
|
||||||
|
): Promise<void> {
|
||||||
|
const get = fetcher.path(CREDIT_NOTES_ROUTES.APPLY_INVOICES).method('get').create();
|
||||||
|
await get({ creditNoteId });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function applyCreditNoteToInvoices(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
creditNoteId: number,
|
||||||
|
values: ApplyCreditNoteToInvoicesBody
|
||||||
|
): Promise<void> {
|
||||||
|
const apply = fetcher.path(CREDIT_NOTES_ROUTES.APPLY_INVOICES).method('post').create();
|
||||||
|
await apply({ creditNoteId, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteApplyCreditNoteToInvoices(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
applyCreditToInvoicesId: number
|
||||||
|
): Promise<void> {
|
||||||
|
const del = fetcher.path(CREDIT_NOTES_ROUTES.APPLIED_INVOICE_BY_ID).method('delete').create();
|
||||||
|
await del({ applyCreditToInvoicesId });
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const CURRENCIES_ROUTES = {
|
||||||
|
LIST: '/api/currencies',
|
||||||
|
BY_ID: '/api/currencies/{id}',
|
||||||
|
BY_CODE: '/api/currencies/{code}',
|
||||||
|
BY_CURRENCY_CODE: '/api/currencies/{currencyCode}',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetCurrencies = paths[typeof CURRENCIES_ROUTES.LIST]['get'];
|
||||||
|
type GetCurrencyByCode = paths[typeof CURRENCIES_ROUTES.BY_CURRENCY_CODE]['get'];
|
||||||
|
|
||||||
|
type GetCurrencies200 = GetCurrencies['responses'][200];
|
||||||
|
type GetCurrencyByCode200 = GetCurrencyByCode['responses'][200];
|
||||||
|
export type CurrenciesListResponse = GetCurrencies200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type Currency = GetCurrencyByCode200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchCurrencies(fetcher: ApiFetcher): Promise<CurrenciesListResponse> {
|
||||||
|
const get = fetcher.path(CURRENCIES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchCurrencyByCode(fetcher: ApiFetcher, currencyCode: string): Promise<Currency> {
|
||||||
|
const get = fetcher.path(CURRENCIES_ROUTES.BY_CURRENCY_CODE).method('get').create();
|
||||||
|
const { data } = await get({ currencyCode });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated Use fetchCurrencyByCode - schema has no get by id */
|
||||||
|
export async function fetchCurrency(fetcher: ApiFetcher, id: number): Promise<Currency> {
|
||||||
|
return fetchCurrencyByCode(fetcher, String(id));
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const CUSTOMERS_ROUTES = {
|
||||||
|
LIST: '/api/customers',
|
||||||
|
BY_ID: '/api/customers/{id}',
|
||||||
|
OPENING_BALANCE: '/api/customers/{id}/opening-balance',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/customers/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/customers/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetCustomers = paths[typeof CUSTOMERS_ROUTES.LIST]['get'];
|
||||||
|
type GetCustomer = paths[typeof CUSTOMERS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateCustomer = paths[typeof CUSTOMERS_ROUTES.LIST]['post'];
|
||||||
|
type EditCustomer = paths[typeof CUSTOMERS_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteCustomer = paths[typeof CUSTOMERS_ROUTES.BY_ID]['delete'];
|
||||||
|
type ValidateBulkDelete = paths[typeof CUSTOMERS_ROUTES.VALIDATE_BULK_DELETE]['post'];
|
||||||
|
type BulkDelete = paths[typeof CUSTOMERS_ROUTES.BULK_DELETE]['post'];
|
||||||
|
|
||||||
|
export type CustomersListResponse = GetCustomers['responses'][200]['content']['application/json'];
|
||||||
|
export type Customer = GetCustomer['responses'][200]['content']['application/json'];
|
||||||
|
export type CreateCustomerBody = CreateCustomer['requestBody']['content']['application/json'];
|
||||||
|
export type EditCustomerBody = EditCustomer['requestBody']['content']['application/json'];
|
||||||
|
export type ValidateBulkDeleteCustomersResponse = ValidateBulkDelete['responses'][200]['content']['application/json'];
|
||||||
|
export type BulkDeleteCustomersBody = BulkDelete['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchCustomers(fetcher: ApiFetcher): Promise<CustomersListResponse> {
|
||||||
|
const get = fetcher.path(CUSTOMERS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchCustomer(fetcher: ApiFetcher, id: number): Promise<Customer> {
|
||||||
|
const get = fetcher.path(CUSTOMERS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createCustomer(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateCustomerBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(CUSTOMERS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editCustomer(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditCustomerBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(CUSTOMERS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteCustomer(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(CUSTOMERS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function validateBulkDeleteCustomers(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: BulkDeleteCustomersBody
|
||||||
|
): Promise<ValidateBulkDeleteCustomersResponse> {
|
||||||
|
const validate = fetcher.path(CUSTOMERS_ROUTES.VALIDATE_BULK_DELETE).method('post').create();
|
||||||
|
const { data } = await validate(body);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function bulkDeleteCustomers(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: BulkDeleteCustomersBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(CUSTOMERS_ROUTES.BULK_DELETE).method('post').create();
|
||||||
|
await post(body);
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const EXPENSES_ROUTES = {
|
||||||
|
LIST: '/api/expenses',
|
||||||
|
BY_ID: '/api/expenses/{id}',
|
||||||
|
PUBLISH: '/api/expenses/{id}/publish',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/expenses/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/expenses/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetExpenses = paths[typeof EXPENSES_ROUTES.LIST]['get'];
|
||||||
|
type GetExpense = paths[typeof EXPENSES_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateExpense = paths[typeof EXPENSES_ROUTES.LIST]['post'];
|
||||||
|
type EditExpense = paths[typeof EXPENSES_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteExpense = paths[typeof EXPENSES_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetExpenses200 = GetExpenses['responses'][200];
|
||||||
|
type GetExpense200 = GetExpense['responses'][200];
|
||||||
|
export type ExpensesListResponse = GetExpenses200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type Expense = GetExpense200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateExpenseBody = CreateExpense['requestBody']['content']['application/json'];
|
||||||
|
export type EditExpenseBody = EditExpense['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchExpenses(fetcher: ApiFetcher): Promise<ExpensesListResponse> {
|
||||||
|
const get = fetcher.path(EXPENSES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchExpense(fetcher: ApiFetcher, id: number): Promise<Expense> {
|
||||||
|
const get = fetcher.path(EXPENSES_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createExpense(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateExpenseBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(EXPENSES_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editExpense(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditExpenseBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(EXPENSES_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteExpense(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(EXPENSES_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function publishExpense(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const post = fetcher.path(EXPENSES_ROUTES.PUBLISH).method('post').create();
|
||||||
|
await post({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Fetcher } from 'openapi-typescript-fetch';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export type ApiFetcher = ReturnType<typeof Fetcher.for<paths>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strips leading slash from a path segment to avoid double slashes when joining with a base (e.g. `/api/` + path).
|
||||||
|
*/
|
||||||
|
export function normalizeApiPath(path: string): string {
|
||||||
|
return (path || '').replace(/^\//, '');
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const GENERIC_RESOURCE_ROUTES = {
|
||||||
|
META: '/api/resources/{resourceModel}/meta',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetResourceMeta = paths[typeof GENERIC_RESOURCE_ROUTES.META]['get'];
|
||||||
|
|
||||||
|
type GetResourceMeta200 = GetResourceMeta['responses'][200];
|
||||||
|
export type ResourceMetaResponse = GetResourceMeta200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchResourceMeta(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
resourceModel: string
|
||||||
|
): Promise<ResourceMetaResponse> {
|
||||||
|
const get = fetcher.path(GENERIC_RESOURCE_ROUTES.META).method('get').create();
|
||||||
|
const { data } = await get({ resourceModel });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,434 @@
|
|||||||
|
/**
|
||||||
|
* Re-export OpenAPI-generated types for use by server and webapp.
|
||||||
|
* Run `pnpm run generate:sdk-types` from repo root to regenerate schema from the server OpenAPI spec.
|
||||||
|
*/
|
||||||
|
export type { paths, components, operations } from './schema';
|
||||||
|
export { normalizeApiPath, ApiFetcher } from './fetch-utils';
|
||||||
|
export {
|
||||||
|
ACCOUNTS_ROUTES,
|
||||||
|
fetchAccounts,
|
||||||
|
fetchAccount,
|
||||||
|
fetchAccountTypes,
|
||||||
|
fetchAccountTransactions,
|
||||||
|
createAccount,
|
||||||
|
editAccount,
|
||||||
|
deleteAccount,
|
||||||
|
activateAccount,
|
||||||
|
inactivateAccount,
|
||||||
|
bulkDeleteAccounts,
|
||||||
|
validateBulkDeleteAccounts,
|
||||||
|
} from './accounts';
|
||||||
|
export type {
|
||||||
|
AccountsList,
|
||||||
|
Account,
|
||||||
|
AccountTypesList,
|
||||||
|
AccountTransactionsList,
|
||||||
|
CreateAccountBody,
|
||||||
|
EditAccountBody,
|
||||||
|
BulkDeleteBody,
|
||||||
|
ValidateBulkDeleteResponse,
|
||||||
|
GetAccountsQuery,
|
||||||
|
} from './accounts';
|
||||||
|
export {
|
||||||
|
CREDIT_NOTES_ROUTES,
|
||||||
|
fetchCreditNotes,
|
||||||
|
fetchCreditNote,
|
||||||
|
fetchCreditNoteState,
|
||||||
|
createCreditNote,
|
||||||
|
editCreditNote,
|
||||||
|
deleteCreditNote,
|
||||||
|
openCreditNote,
|
||||||
|
validateBulkDeleteCreditNotes,
|
||||||
|
bulkDeleteCreditNotes,
|
||||||
|
fetchCreditNoteRefunds,
|
||||||
|
createRefundCreditNote,
|
||||||
|
deleteRefundCreditNote,
|
||||||
|
fetchAppliedInvoices,
|
||||||
|
fetchCreditNoteAssociatedInvoicesToApply,
|
||||||
|
applyCreditNoteToInvoices,
|
||||||
|
deleteApplyCreditNoteToInvoices,
|
||||||
|
} from './credit-notes';
|
||||||
|
export type {
|
||||||
|
CreditNotesListResponse,
|
||||||
|
CreditNote,
|
||||||
|
CreateCreditNoteBody,
|
||||||
|
EditCreditNoteBody,
|
||||||
|
ValidateBulkDeleteCreditNotesBody,
|
||||||
|
ValidateBulkDeleteCreditNotesResponse,
|
||||||
|
BulkDeleteCreditNotesBody,
|
||||||
|
CreateRefundCreditNoteBody,
|
||||||
|
ApplyCreditNoteToInvoicesBody,
|
||||||
|
} from './credit-notes';
|
||||||
|
export {
|
||||||
|
API_KEYS_ROUTES,
|
||||||
|
fetchApiKeys,
|
||||||
|
generateApiKey,
|
||||||
|
revokeApiKey,
|
||||||
|
} from './api-keys';
|
||||||
|
export type { ApiKeysList, GenerateApiKeyBody } from './api-keys';
|
||||||
|
export {
|
||||||
|
SALE_INVOICES_ROUTES,
|
||||||
|
fetchSaleInvoices,
|
||||||
|
fetchSaleInvoice,
|
||||||
|
createSaleInvoice,
|
||||||
|
editSaleInvoice,
|
||||||
|
deleteSaleInvoice,
|
||||||
|
} from './sale-invoices';
|
||||||
|
export type {
|
||||||
|
SaleInvoicesListResponse,
|
||||||
|
SaleInvoice,
|
||||||
|
CreateSaleInvoiceBody,
|
||||||
|
EditSaleInvoiceBody,
|
||||||
|
} from './sale-invoices';
|
||||||
|
export {
|
||||||
|
CUSTOMERS_ROUTES,
|
||||||
|
fetchCustomers,
|
||||||
|
fetchCustomer,
|
||||||
|
createCustomer,
|
||||||
|
editCustomer,
|
||||||
|
deleteCustomer,
|
||||||
|
validateBulkDeleteCustomers,
|
||||||
|
bulkDeleteCustomers,
|
||||||
|
} from './customers';
|
||||||
|
export type {
|
||||||
|
CustomersListResponse,
|
||||||
|
Customer,
|
||||||
|
CreateCustomerBody,
|
||||||
|
EditCustomerBody,
|
||||||
|
ValidateBulkDeleteCustomersResponse,
|
||||||
|
BulkDeleteCustomersBody,
|
||||||
|
} from './customers';
|
||||||
|
export {
|
||||||
|
VENDORS_ROUTES,
|
||||||
|
fetchVendors,
|
||||||
|
fetchVendor,
|
||||||
|
createVendor,
|
||||||
|
editVendor,
|
||||||
|
deleteVendor,
|
||||||
|
validateBulkDeleteVendors,
|
||||||
|
bulkDeleteVendors,
|
||||||
|
} from './vendors';
|
||||||
|
export type {
|
||||||
|
VendorsListResponse,
|
||||||
|
Vendor,
|
||||||
|
CreateVendorBody,
|
||||||
|
EditVendorBody,
|
||||||
|
ValidateBulkDeleteVendorsResponse,
|
||||||
|
BulkDeleteVendorsBody,
|
||||||
|
} from './vendors';
|
||||||
|
export {
|
||||||
|
BILLS_ROUTES,
|
||||||
|
fetchBills,
|
||||||
|
fetchBill,
|
||||||
|
createBill,
|
||||||
|
editBill,
|
||||||
|
deleteBill,
|
||||||
|
} from './bills';
|
||||||
|
export type {
|
||||||
|
BillsListResponse,
|
||||||
|
Bill,
|
||||||
|
CreateBillBody,
|
||||||
|
EditBillBody,
|
||||||
|
} from './bills';
|
||||||
|
export {
|
||||||
|
ITEMS_ROUTES,
|
||||||
|
fetchItems,
|
||||||
|
fetchItem,
|
||||||
|
createItem,
|
||||||
|
editItem,
|
||||||
|
deleteItem,
|
||||||
|
inactivateItem,
|
||||||
|
activateItem,
|
||||||
|
validateBulkDeleteItems,
|
||||||
|
bulkDeleteItems,
|
||||||
|
} from './items';
|
||||||
|
export type {
|
||||||
|
ItemsListResponse,
|
||||||
|
Item,
|
||||||
|
CreateItemBody,
|
||||||
|
EditItemBody,
|
||||||
|
BulkDeleteItemsBody,
|
||||||
|
ValidateBulkDeleteItemsResponse,
|
||||||
|
} from './items';
|
||||||
|
export {
|
||||||
|
BRANCHES_ROUTES,
|
||||||
|
fetchBranches,
|
||||||
|
fetchBranch,
|
||||||
|
createBranch,
|
||||||
|
editBranch,
|
||||||
|
deleteBranch,
|
||||||
|
activateBranches,
|
||||||
|
markBranchAsPrimary,
|
||||||
|
} from './branches';
|
||||||
|
export type {
|
||||||
|
BranchesListResponse,
|
||||||
|
Branch,
|
||||||
|
CreateBranchBody,
|
||||||
|
EditBranchBody,
|
||||||
|
} from './branches';
|
||||||
|
export {
|
||||||
|
WAREHOUSES_ROUTES,
|
||||||
|
fetchWarehouses,
|
||||||
|
fetchWarehouse,
|
||||||
|
createWarehouse,
|
||||||
|
editWarehouse,
|
||||||
|
deleteWarehouse,
|
||||||
|
activateWarehouses,
|
||||||
|
markWarehousePrimary,
|
||||||
|
} from './warehouses';
|
||||||
|
export type {
|
||||||
|
WarehousesListResponse,
|
||||||
|
Warehouse,
|
||||||
|
CreateWarehouseBody,
|
||||||
|
EditWarehouseBody,
|
||||||
|
} from './warehouses';
|
||||||
|
export {
|
||||||
|
EXPENSES_ROUTES,
|
||||||
|
fetchExpenses,
|
||||||
|
fetchExpense,
|
||||||
|
createExpense,
|
||||||
|
editExpense,
|
||||||
|
deleteExpense,
|
||||||
|
publishExpense,
|
||||||
|
} from './expenses';
|
||||||
|
export type {
|
||||||
|
ExpensesListResponse,
|
||||||
|
Expense,
|
||||||
|
CreateExpenseBody,
|
||||||
|
EditExpenseBody,
|
||||||
|
} from './expenses';
|
||||||
|
export {
|
||||||
|
MANUAL_JOURNALS_ROUTES,
|
||||||
|
fetchManualJournals,
|
||||||
|
fetchManualJournal,
|
||||||
|
createManualJournal,
|
||||||
|
editManualJournal,
|
||||||
|
deleteManualJournal,
|
||||||
|
publishManualJournal,
|
||||||
|
} from './manual-journals';
|
||||||
|
export type {
|
||||||
|
ManualJournalsListResponse,
|
||||||
|
ManualJournal,
|
||||||
|
CreateManualJournalBody,
|
||||||
|
EditManualJournalBody,
|
||||||
|
} from './manual-journals';
|
||||||
|
export {
|
||||||
|
ROLES_ROUTES,
|
||||||
|
fetchRoles,
|
||||||
|
fetchRole,
|
||||||
|
createRole,
|
||||||
|
editRole,
|
||||||
|
deleteRole,
|
||||||
|
fetchRolePermissionsSchema,
|
||||||
|
} from './roles';
|
||||||
|
export type {
|
||||||
|
RolesListResponse,
|
||||||
|
Role,
|
||||||
|
CreateRoleBody,
|
||||||
|
EditRoleBody,
|
||||||
|
RolePermissionsSchema,
|
||||||
|
} from './roles';
|
||||||
|
export {
|
||||||
|
USERS_ROUTES,
|
||||||
|
fetchUsers,
|
||||||
|
fetchUser,
|
||||||
|
editUser,
|
||||||
|
deleteUser,
|
||||||
|
activateUser,
|
||||||
|
inactivateUser,
|
||||||
|
} from './users';
|
||||||
|
export type {
|
||||||
|
UsersListResponse,
|
||||||
|
User,
|
||||||
|
EditUserBody,
|
||||||
|
GetUsersQuery,
|
||||||
|
} from './users';
|
||||||
|
export {
|
||||||
|
SETTINGS_ROUTES,
|
||||||
|
fetchSettings,
|
||||||
|
saveSettings,
|
||||||
|
} from './settings';
|
||||||
|
export type { SettingsResponse, SaveSettingsBody } from './settings';
|
||||||
|
export {
|
||||||
|
ORGANIZATION_ROUTES,
|
||||||
|
fetchOrganizationCurrent,
|
||||||
|
fetchOrganization,
|
||||||
|
updateOrganization,
|
||||||
|
} from './organization';
|
||||||
|
export type {
|
||||||
|
OrganizationCurrent,
|
||||||
|
Organization,
|
||||||
|
UpdateOrganizationBody,
|
||||||
|
} from './organization';
|
||||||
|
export {
|
||||||
|
SUBSCRIPTION_ROUTES,
|
||||||
|
fetchSubscriptions,
|
||||||
|
cancelSubscription,
|
||||||
|
resumeSubscription,
|
||||||
|
} from './subscription';
|
||||||
|
export type { SubscriptionsListResponse } from './subscription';
|
||||||
|
export {
|
||||||
|
CURRENCIES_ROUTES,
|
||||||
|
fetchCurrencies,
|
||||||
|
fetchCurrency,
|
||||||
|
fetchCurrencyByCode,
|
||||||
|
} from './currencies';
|
||||||
|
export type { CurrenciesListResponse, Currency } from './currencies';
|
||||||
|
export {
|
||||||
|
INVITE_ROUTES,
|
||||||
|
inviteUser,
|
||||||
|
resendInvite,
|
||||||
|
} from './invite';
|
||||||
|
export type { InviteUserBody } from './invite';
|
||||||
|
export {
|
||||||
|
AUTH_ROUTES,
|
||||||
|
fetchAuthedAccount,
|
||||||
|
} from './authentication';
|
||||||
|
export type { AuthedAccount } from './authentication';
|
||||||
|
export {
|
||||||
|
CONTACTS_ROUTES,
|
||||||
|
fetchContactsAutoComplete,
|
||||||
|
activateContact,
|
||||||
|
inactivateContact,
|
||||||
|
} from './contacts';
|
||||||
|
export type { ContactsAutoCompleteResponse } from './contacts';
|
||||||
|
export {
|
||||||
|
ITEMS_CATEGORIES_ROUTES,
|
||||||
|
fetchItemCategories,
|
||||||
|
fetchItemCategory,
|
||||||
|
createItemCategory,
|
||||||
|
editItemCategory,
|
||||||
|
deleteItemCategory,
|
||||||
|
} from './items-categories';
|
||||||
|
export type {
|
||||||
|
ItemCategoriesListResponse,
|
||||||
|
ItemCategory,
|
||||||
|
CreateItemCategoryBody,
|
||||||
|
EditItemCategoryBody,
|
||||||
|
} from './items-categories';
|
||||||
|
export {
|
||||||
|
VIEWS_ROUTES,
|
||||||
|
fetchResourceView,
|
||||||
|
} from './views';
|
||||||
|
export type { ResourceViewResponse } from './views';
|
||||||
|
export {
|
||||||
|
TRANSACTIONS_LOCKING_ROUTES,
|
||||||
|
fetchTransactionsLocking,
|
||||||
|
fetchTransactionsLockingByModule,
|
||||||
|
} from './transactions-locking';
|
||||||
|
export {
|
||||||
|
VENDOR_CREDITS_ROUTES,
|
||||||
|
fetchVendorCredits,
|
||||||
|
fetchVendorCredit,
|
||||||
|
createVendorCredit,
|
||||||
|
editVendorCredit,
|
||||||
|
deleteVendorCredit,
|
||||||
|
openVendorCredit,
|
||||||
|
} from './vendor-credits';
|
||||||
|
export type {
|
||||||
|
VendorCreditsListResponse,
|
||||||
|
VendorCredit,
|
||||||
|
CreateVendorCreditBody,
|
||||||
|
EditVendorCreditBody,
|
||||||
|
} from './vendor-credits';
|
||||||
|
export {
|
||||||
|
SALE_ESTIMATES_ROUTES,
|
||||||
|
fetchSaleEstimates,
|
||||||
|
fetchSaleEstimate,
|
||||||
|
createSaleEstimate,
|
||||||
|
editSaleEstimate,
|
||||||
|
deleteSaleEstimate,
|
||||||
|
} from './sale-estimates';
|
||||||
|
export type {
|
||||||
|
SaleEstimatesListResponse,
|
||||||
|
SaleEstimate,
|
||||||
|
CreateSaleEstimateBody,
|
||||||
|
EditSaleEstimateBody,
|
||||||
|
} from './sale-estimates';
|
||||||
|
export {
|
||||||
|
SALE_RECEIPTS_ROUTES,
|
||||||
|
fetchSaleReceipts,
|
||||||
|
fetchSaleReceipt,
|
||||||
|
createSaleReceipt,
|
||||||
|
editSaleReceipt,
|
||||||
|
deleteSaleReceipt,
|
||||||
|
} from './sale-receipts';
|
||||||
|
export type {
|
||||||
|
SaleReceiptsListResponse,
|
||||||
|
SaleReceipt,
|
||||||
|
CreateSaleReceiptBody,
|
||||||
|
EditSaleReceiptBody,
|
||||||
|
} from './sale-receipts';
|
||||||
|
export {
|
||||||
|
PAYMENTS_RECEIVED_ROUTES,
|
||||||
|
fetchPaymentsReceived,
|
||||||
|
fetchPaymentReceived,
|
||||||
|
createPaymentReceived,
|
||||||
|
editPaymentReceived,
|
||||||
|
deletePaymentReceived,
|
||||||
|
} from './payment-receives';
|
||||||
|
export type {
|
||||||
|
PaymentsReceivedListResponse,
|
||||||
|
PaymentReceived,
|
||||||
|
CreatePaymentReceivedBody,
|
||||||
|
EditPaymentReceivedBody,
|
||||||
|
} from './payment-receives';
|
||||||
|
export {
|
||||||
|
BILL_PAYMENTS_ROUTES,
|
||||||
|
fetchBillPayments,
|
||||||
|
fetchBillPayment,
|
||||||
|
createBillPayment,
|
||||||
|
editBillPayment,
|
||||||
|
deleteBillPayment,
|
||||||
|
} from './payment-mades';
|
||||||
|
export type {
|
||||||
|
BillPaymentsListResponse,
|
||||||
|
BillPayment,
|
||||||
|
CreateBillPaymentBody,
|
||||||
|
EditBillPaymentBody,
|
||||||
|
} from './payment-mades';
|
||||||
|
export {
|
||||||
|
INVENTORY_ADJUSTMENTS_ROUTES,
|
||||||
|
fetchInventoryAdjustments,
|
||||||
|
fetchInventoryAdjustment,
|
||||||
|
createQuickInventoryAdjustment,
|
||||||
|
deleteInventoryAdjustment,
|
||||||
|
publishInventoryAdjustment,
|
||||||
|
} from './inventory-adjustments';
|
||||||
|
export type {
|
||||||
|
InventoryAdjustmentsListResponse,
|
||||||
|
InventoryAdjustment,
|
||||||
|
CreateQuickInventoryAdjustmentBody,
|
||||||
|
} from './inventory-adjustments';
|
||||||
|
export {
|
||||||
|
WAREHOUSE_TRANSFERS_ROUTES,
|
||||||
|
fetchWarehouseTransfers,
|
||||||
|
fetchWarehouseTransfer,
|
||||||
|
createWarehouseTransfer,
|
||||||
|
editWarehouseTransfer,
|
||||||
|
deleteWarehouseTransfer,
|
||||||
|
initiateWarehouseTransfer,
|
||||||
|
transferredWarehouseTransfer,
|
||||||
|
} from './warehouse-transfers';
|
||||||
|
export type {
|
||||||
|
WarehouseTransfersListResponse,
|
||||||
|
WarehouseTransfer,
|
||||||
|
CreateWarehouseTransferBody,
|
||||||
|
EditWarehouseTransferBody,
|
||||||
|
} from './warehouse-transfers';
|
||||||
|
export {
|
||||||
|
LANDED_COST_ROUTES,
|
||||||
|
fetchLandedCostTransactions,
|
||||||
|
} from './landed-cost';
|
||||||
|
export type { LandedCostTransactionsResponse } from './landed-cost';
|
||||||
|
export {
|
||||||
|
GENERIC_RESOURCE_ROUTES,
|
||||||
|
fetchResourceMeta,
|
||||||
|
} from './generic-resource';
|
||||||
|
export type { ResourceMetaResponse } from './generic-resource';
|
||||||
|
export {
|
||||||
|
BANKING_ACCOUNTS_ROUTES,
|
||||||
|
fetchBankingAccounts,
|
||||||
|
fetchBankingAccountSummary,
|
||||||
|
} from './cashflow-accounts';
|
||||||
|
export type { BankingAccountsListResponse } from './cashflow-accounts';
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const INVENTORY_ADJUSTMENTS_ROUTES = {
|
||||||
|
LIST: '/api/inventory-adjustments',
|
||||||
|
BY_ID: '/api/inventory-adjustments/{id}',
|
||||||
|
QUICK: '/api/inventory-adjustments/quick',
|
||||||
|
PUBLISH: '/api/inventory-adjustments/{id}/publish',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetInventoryAdjustments = paths[typeof INVENTORY_ADJUSTMENTS_ROUTES.LIST]['get'];
|
||||||
|
type GetInventoryAdjustment = paths[typeof INVENTORY_ADJUSTMENTS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateQuick = paths[typeof INVENTORY_ADJUSTMENTS_ROUTES.QUICK]['post'];
|
||||||
|
type DeleteInventoryAdjustment = paths[typeof INVENTORY_ADJUSTMENTS_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetInventoryAdjustments200 = GetInventoryAdjustments['responses'][200];
|
||||||
|
type GetInventoryAdjustment200 = GetInventoryAdjustment['responses'][200];
|
||||||
|
export type InventoryAdjustmentsListResponse = GetInventoryAdjustments200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type InventoryAdjustment = GetInventoryAdjustment200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateQuickInventoryAdjustmentBody = CreateQuick['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchInventoryAdjustments(fetcher: ApiFetcher): Promise<InventoryAdjustmentsListResponse> {
|
||||||
|
const get = fetcher.path(INVENTORY_ADJUSTMENTS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchInventoryAdjustment(fetcher: ApiFetcher, id: number): Promise<InventoryAdjustment> {
|
||||||
|
const get = fetcher.path(INVENTORY_ADJUSTMENTS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createQuickInventoryAdjustment(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateQuickInventoryAdjustmentBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(INVENTORY_ADJUSTMENTS_ROUTES.QUICK).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteInventoryAdjustment(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(INVENTORY_ADJUSTMENTS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function publishInventoryAdjustment(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const put = fetcher.path(INVENTORY_ADJUSTMENTS_ROUTES.PUBLISH).method('put').create();
|
||||||
|
await put({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const INVITE_ROUTES = {
|
||||||
|
INVITE: '/api/invite',
|
||||||
|
RESEND: '/api/invite/users/{id}/resend',
|
||||||
|
ACCEPT: '/api/invite/accept/{token}',
|
||||||
|
CHECK: '/api/invite/check/{token}',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type InviteUser = paths[typeof INVITE_ROUTES.INVITE]['patch'];
|
||||||
|
type ResendInvite = paths[typeof INVITE_ROUTES.RESEND]['post'];
|
||||||
|
|
||||||
|
export type InviteUserBody = InviteUser['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function inviteUser(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: InviteUserBody
|
||||||
|
): Promise<void> {
|
||||||
|
const patch = fetcher.path(INVITE_ROUTES.INVITE).method('patch').create();
|
||||||
|
await patch(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resendInvite(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const post = fetcher.path(INVITE_ROUTES.RESEND).method('post').create();
|
||||||
|
await post({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const ITEMS_CATEGORIES_ROUTES = {
|
||||||
|
LIST: '/api/item-categories',
|
||||||
|
BY_ID: '/api/item-categories/{id}',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetItemCategories = paths[typeof ITEMS_CATEGORIES_ROUTES.LIST]['get'];
|
||||||
|
type GetItemCategory = paths[typeof ITEMS_CATEGORIES_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateItemCategory = paths[typeof ITEMS_CATEGORIES_ROUTES.LIST]['post'];
|
||||||
|
type EditItemCategory = paths[typeof ITEMS_CATEGORIES_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteItemCategory = paths[typeof ITEMS_CATEGORIES_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetItemCategories200 = GetItemCategories['responses'][200];
|
||||||
|
type GetItemCategory200 = GetItemCategory['responses'][200];
|
||||||
|
export type ItemCategoriesListResponse = GetItemCategories200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type ItemCategory = GetItemCategory200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateItemCategoryBody = CreateItemCategory['requestBody']['content']['application/json'];
|
||||||
|
export type EditItemCategoryBody = EditItemCategory['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchItemCategories(fetcher: ApiFetcher): Promise<ItemCategoriesListResponse> {
|
||||||
|
const get = fetcher.path(ITEMS_CATEGORIES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchItemCategory(fetcher: ApiFetcher, id: number): Promise<ItemCategory> {
|
||||||
|
const get = fetcher.path(ITEMS_CATEGORIES_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createItemCategory(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateItemCategoryBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(ITEMS_CATEGORIES_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editItemCategory(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditItemCategoryBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(ITEMS_CATEGORIES_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteItemCategory(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(ITEMS_CATEGORIES_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const ITEMS_ROUTES = {
|
||||||
|
LIST: '/api/items',
|
||||||
|
BY_ID: '/api/items/{id}',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/items/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/items/bulk-delete',
|
||||||
|
INACTIVATE: '/api/items/{id}/inactivate',
|
||||||
|
ACTIVATE: '/api/items/{id}/activate',
|
||||||
|
INVOICES: '/api/items/{id}/invoices',
|
||||||
|
BILLS: '/api/items/{id}/bills',
|
||||||
|
ESTIMATES: '/api/items/{id}/estimates',
|
||||||
|
RECEIPTS: '/api/items/{id}/receipts',
|
||||||
|
WAREHOUSES: '/api/items/{id}/warehouses',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetItems = paths[typeof ITEMS_ROUTES.LIST]['get'];
|
||||||
|
type GetItem = paths[typeof ITEMS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateItem = paths[typeof ITEMS_ROUTES.LIST]['post'];
|
||||||
|
type EditItem = paths[typeof ITEMS_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteItem = paths[typeof ITEMS_ROUTES.BY_ID]['delete'];
|
||||||
|
type BulkDelete = paths[typeof ITEMS_ROUTES.BULK_DELETE]['post'];
|
||||||
|
type ValidateBulkDelete = paths[typeof ITEMS_ROUTES.VALIDATE_BULK_DELETE]['post'];
|
||||||
|
|
||||||
|
export type ItemsListResponse = GetItems['responses'][200]['content']['application/json'];
|
||||||
|
export type Item = GetItem['responses'][200]['content']['application/json'];
|
||||||
|
export type CreateItemBody = CreateItem['requestBody']['content']['application/json'];
|
||||||
|
export type EditItemBody = EditItem['requestBody']['content']['application/json'];
|
||||||
|
export type BulkDeleteItemsBody = BulkDelete['requestBody']['content']['application/json'];
|
||||||
|
export type ValidateBulkDeleteItemsResponse = ValidateBulkDelete['responses'][200]['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchItems(fetcher: ApiFetcher): Promise<ItemsListResponse> {
|
||||||
|
const get = fetcher.path(ITEMS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchItem(fetcher: ApiFetcher, id: number): Promise<Item> {
|
||||||
|
const get = fetcher.path(ITEMS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createItem(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateItemBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(ITEMS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editItem(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditItemBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(ITEMS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteItem(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(ITEMS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function inactivateItem(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const patch = fetcher.path(ITEMS_ROUTES.INACTIVATE).method('patch').create();
|
||||||
|
await patch({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activateItem(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const patch = fetcher.path(ITEMS_ROUTES.ACTIVATE).method('patch').create();
|
||||||
|
await patch({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function validateBulkDeleteItems(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: BulkDeleteItemsBody
|
||||||
|
): Promise<ValidateBulkDeleteItemsResponse> {
|
||||||
|
const validate = fetcher.path(ITEMS_ROUTES.VALIDATE_BULK_DELETE).method('post').create();
|
||||||
|
const { data } = await validate(body);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function bulkDeleteItems(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: BulkDeleteItemsBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(ITEMS_ROUTES.BULK_DELETE).method('post').create();
|
||||||
|
await post(body);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const LANDED_COST_ROUTES = {
|
||||||
|
TRANSACTIONS: '/api/landed-cost/transactions',
|
||||||
|
ALLOCATE: '/api/landed-cost/bills/{billId}/allocate',
|
||||||
|
BY_ID: '/api/landed-cost/{allocatedLandedCostId}',
|
||||||
|
BILL_TRANSACTIONS: '/api/landed-cost/bills/{billId}/transactions',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetLandedCostTransactions = paths[typeof LANDED_COST_ROUTES.TRANSACTIONS]['get'];
|
||||||
|
|
||||||
|
type GetLandedCostTransactions200 = GetLandedCostTransactions['responses'][200];
|
||||||
|
export type LandedCostTransactionsResponse = GetLandedCostTransactions200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchLandedCostTransactions(fetcher: ApiFetcher): Promise<LandedCostTransactionsResponse> {
|
||||||
|
const get = fetcher.path(LANDED_COST_ROUTES.TRANSACTIONS).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const MANUAL_JOURNALS_ROUTES = {
|
||||||
|
LIST: '/api/manual-journals',
|
||||||
|
BY_ID: '/api/manual-journals/{id}',
|
||||||
|
PUBLISH: '/api/manual-journals/{id}/publish',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/manual-journals/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/manual-journals/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetManualJournals = paths[typeof MANUAL_JOURNALS_ROUTES.LIST]['get'];
|
||||||
|
type GetManualJournal = paths[typeof MANUAL_JOURNALS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateManualJournal = paths[typeof MANUAL_JOURNALS_ROUTES.LIST]['post'];
|
||||||
|
type EditManualJournal = paths[typeof MANUAL_JOURNALS_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteManualJournal = paths[typeof MANUAL_JOURNALS_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetManualJournals200 = GetManualJournals['responses'][200];
|
||||||
|
type GetManualJournal200 = GetManualJournal['responses'][200];
|
||||||
|
export type ManualJournalsListResponse = GetManualJournals200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type ManualJournal = GetManualJournal200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateManualJournalBody = CreateManualJournal['requestBody']['content']['application/json'];
|
||||||
|
export type EditManualJournalBody = EditManualJournal['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchManualJournals(fetcher: ApiFetcher): Promise<ManualJournalsListResponse> {
|
||||||
|
const get = fetcher.path(MANUAL_JOURNALS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchManualJournal(fetcher: ApiFetcher, id: number): Promise<ManualJournal> {
|
||||||
|
const get = fetcher.path(MANUAL_JOURNALS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createManualJournal(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateManualJournalBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(MANUAL_JOURNALS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editManualJournal(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditManualJournalBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(MANUAL_JOURNALS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteManualJournal(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(MANUAL_JOURNALS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function publishManualJournal(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const patch = fetcher.path(MANUAL_JOURNALS_ROUTES.PUBLISH).method('patch').create();
|
||||||
|
await patch({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const ORGANIZATION_ROUTES = {
|
||||||
|
CURRENT: '/api/organization/current',
|
||||||
|
BUILD: '/api/organization/build',
|
||||||
|
BUILD_JOB: '/api/organization/build/{buildJobId}',
|
||||||
|
BASE_CURRENCY_MUTATE: '/api/organization/base-currency-mutate',
|
||||||
|
UPDATE: '/api/organization',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetCurrent = paths[typeof ORGANIZATION_ROUTES.CURRENT]['get'];
|
||||||
|
type UpdateOrganization = paths[typeof ORGANIZATION_ROUTES.UPDATE]['put'];
|
||||||
|
|
||||||
|
type GetCurrent200 = GetCurrent['responses'][200];
|
||||||
|
export type OrganizationCurrent = GetCurrent200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type UpdateOrganizationBody = UpdateOrganization['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchOrganizationCurrent(fetcher: ApiFetcher): Promise<OrganizationCurrent> {
|
||||||
|
const get = fetcher.path(ORGANIZATION_ROUTES.CURRENT).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateOrganization(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: UpdateOrganizationBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(ORGANIZATION_ROUTES.UPDATE).method('put').create();
|
||||||
|
await put(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Organization = OrganizationCurrent;
|
||||||
|
export async function fetchOrganization(fetcher: ApiFetcher): Promise<Organization> {
|
||||||
|
return fetchOrganizationCurrent(fetcher);
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const BILL_PAYMENTS_ROUTES = {
|
||||||
|
LIST: '/api/bill-payments',
|
||||||
|
BY_ID: '/api/bill-payments/{billPaymentId}',
|
||||||
|
NEW_PAGE_ENTRIES: '/api/bill-payments/new-page/entries',
|
||||||
|
BILLS: '/api/bill-payments/{billPaymentId}/bills',
|
||||||
|
EDIT_PAGE: '/api/bill-payments/{billPaymentId}/edit-page',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetBillPayments = paths[typeof BILL_PAYMENTS_ROUTES.LIST]['get'];
|
||||||
|
type GetBillPayment = paths[typeof BILL_PAYMENTS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateBillPayment = paths[typeof BILL_PAYMENTS_ROUTES.LIST]['post'];
|
||||||
|
type EditBillPayment = paths[typeof BILL_PAYMENTS_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteBillPayment = paths[typeof BILL_PAYMENTS_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetBillPayments200 = GetBillPayments['responses'][200];
|
||||||
|
type GetBillPayment200 = GetBillPayment['responses'][200];
|
||||||
|
export type BillPaymentsListResponse = GetBillPayments200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type BillPayment = GetBillPayment200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateBillPaymentBody = CreateBillPayment['requestBody']['content']['application/json'];
|
||||||
|
export type EditBillPaymentBody = EditBillPayment['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchBillPayments(fetcher: ApiFetcher): Promise<BillPaymentsListResponse> {
|
||||||
|
const get = fetcher.path(BILL_PAYMENTS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchBillPayment(fetcher: ApiFetcher, billPaymentId: number): Promise<BillPayment> {
|
||||||
|
const get = fetcher.path(BILL_PAYMENTS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ billPaymentId });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createBillPayment(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateBillPaymentBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(BILL_PAYMENTS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editBillPayment(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
billPaymentId: number,
|
||||||
|
values: EditBillPaymentBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(BILL_PAYMENTS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ billPaymentId, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteBillPayment(fetcher: ApiFetcher, billPaymentId: number): Promise<void> {
|
||||||
|
const del = fetcher.path(BILL_PAYMENTS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ billPaymentId });
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const PAYMENTS_RECEIVED_ROUTES = {
|
||||||
|
LIST: '/api/payments-received',
|
||||||
|
BY_ID: '/api/payments-received/{id}',
|
||||||
|
STATE: '/api/payments-received/state',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/payments-received/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/payments-received/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetPaymentsReceived = paths[typeof PAYMENTS_RECEIVED_ROUTES.LIST]['get'];
|
||||||
|
type GetPaymentReceived = paths[typeof PAYMENTS_RECEIVED_ROUTES.BY_ID]['get'];
|
||||||
|
type CreatePaymentReceived = paths[typeof PAYMENTS_RECEIVED_ROUTES.LIST]['post'];
|
||||||
|
type EditPaymentReceived = paths[typeof PAYMENTS_RECEIVED_ROUTES.BY_ID]['put'];
|
||||||
|
type DeletePaymentReceived = paths[typeof PAYMENTS_RECEIVED_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetPaymentsReceived200 = GetPaymentsReceived['responses'][200];
|
||||||
|
type GetPaymentReceived200 = GetPaymentReceived['responses'][200];
|
||||||
|
export type PaymentsReceivedListResponse = GetPaymentsReceived200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type PaymentReceived = GetPaymentReceived200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreatePaymentReceivedBody = CreatePaymentReceived['requestBody']['content']['application/json'];
|
||||||
|
export type EditPaymentReceivedBody = EditPaymentReceived['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchPaymentsReceived(fetcher: ApiFetcher): Promise<PaymentsReceivedListResponse> {
|
||||||
|
const get = fetcher.path(PAYMENTS_RECEIVED_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchPaymentReceived(fetcher: ApiFetcher, id: number): Promise<PaymentReceived> {
|
||||||
|
const get = fetcher.path(PAYMENTS_RECEIVED_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createPaymentReceived(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreatePaymentReceivedBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(PAYMENTS_RECEIVED_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editPaymentReceived(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditPaymentReceivedBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(PAYMENTS_RECEIVED_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deletePaymentReceived(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(PAYMENTS_RECEIVED_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const ROLES_ROUTES = {
|
||||||
|
LIST: '/api/roles',
|
||||||
|
BY_ID: '/api/roles/{id}',
|
||||||
|
PERMISSIONS_SCHEMA: '/api/roles/permissions/schema',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetRoles = paths[typeof ROLES_ROUTES.LIST]['get'];
|
||||||
|
type GetRole = paths[typeof ROLES_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateRole = paths[typeof ROLES_ROUTES.LIST]['post'];
|
||||||
|
type EditRole = paths[typeof ROLES_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteRole = paths[typeof ROLES_ROUTES.BY_ID]['delete'];
|
||||||
|
type GetPermissionsSchema = paths[typeof ROLES_ROUTES.PERMISSIONS_SCHEMA]['get'];
|
||||||
|
|
||||||
|
type GetRoles200 = GetRoles['responses'][200];
|
||||||
|
type GetRole200 = GetRole['responses'][200];
|
||||||
|
type GetPermissionsSchema200 = GetPermissionsSchema['responses'][200];
|
||||||
|
export type RolesListResponse = GetRoles200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type Role = GetRole200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateRoleBody = CreateRole['requestBody']['content']['application/json'];
|
||||||
|
export type EditRoleBody = EditRole['requestBody']['content']['application/json'];
|
||||||
|
export type RolePermissionsSchema = GetPermissionsSchema200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchRoles(fetcher: ApiFetcher): Promise<RolesListResponse> {
|
||||||
|
const get = fetcher.path(ROLES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchRole(fetcher: ApiFetcher, id: number): Promise<Role> {
|
||||||
|
const get = fetcher.path(ROLES_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createRole(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateRoleBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(ROLES_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editRole(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditRoleBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(ROLES_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteRole(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(ROLES_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchRolePermissionsSchema(fetcher: ApiFetcher): Promise<RolePermissionsSchema> {
|
||||||
|
const get = fetcher.path(ROLES_ROUTES.PERMISSIONS_SCHEMA).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const SALE_ESTIMATES_ROUTES = {
|
||||||
|
LIST: '/api/sale-estimates',
|
||||||
|
BY_ID: '/api/sale-estimates/{id}',
|
||||||
|
STATE: '/api/sale-estimates/state',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/sale-estimates/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/sale-estimates/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetSaleEstimates = paths[typeof SALE_ESTIMATES_ROUTES.LIST]['get'];
|
||||||
|
type GetSaleEstimate = paths[typeof SALE_ESTIMATES_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateSaleEstimate = paths[typeof SALE_ESTIMATES_ROUTES.LIST]['post'];
|
||||||
|
type EditSaleEstimate = paths[typeof SALE_ESTIMATES_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteSaleEstimate = paths[typeof SALE_ESTIMATES_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetSaleEstimates200 = GetSaleEstimates['responses'][200];
|
||||||
|
type GetSaleEstimate200 = GetSaleEstimate['responses'][200];
|
||||||
|
export type SaleEstimatesListResponse = GetSaleEstimates200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type SaleEstimate = GetSaleEstimate200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateSaleEstimateBody = CreateSaleEstimate['requestBody']['content']['application/json'];
|
||||||
|
export type EditSaleEstimateBody = EditSaleEstimate['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchSaleEstimates(fetcher: ApiFetcher): Promise<SaleEstimatesListResponse> {
|
||||||
|
const get = fetcher.path(SALE_ESTIMATES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchSaleEstimate(fetcher: ApiFetcher, id: number): Promise<SaleEstimate> {
|
||||||
|
const get = fetcher.path(SALE_ESTIMATES_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createSaleEstimate(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateSaleEstimateBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(SALE_ESTIMATES_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editSaleEstimate(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditSaleEstimateBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(SALE_ESTIMATES_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteSaleEstimate(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(SALE_ESTIMATES_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const SALE_INVOICES_ROUTES = {
|
||||||
|
LIST: '/api/sale-invoices',
|
||||||
|
BY_ID: '/api/sale-invoices/{id}',
|
||||||
|
STATE: '/api/sale-invoices/state',
|
||||||
|
RECEIVABLE: '/api/sale-invoices/receivable',
|
||||||
|
MAIL: '/api/sale-invoices/{id}/mail',
|
||||||
|
DELIVER: '/api/sale-invoices/{id}/deliver',
|
||||||
|
WRITEOFF: '/api/sale-invoices/{id}/writeoff',
|
||||||
|
CANCEL_WRITEOFF: '/api/sale-invoices/{id}/cancel-writeoff',
|
||||||
|
PAYMENTS: '/api/sale-invoices/{id}/payments',
|
||||||
|
HTML: '/api/sale-invoices/{id}/html',
|
||||||
|
GENERATE_LINK: '/api/sale-invoices/{id}/generate-link',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/sale-invoices/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/sale-invoices/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetSaleInvoices = paths[typeof SALE_INVOICES_ROUTES.LIST]['get'];
|
||||||
|
type GetSaleInvoice = paths[typeof SALE_INVOICES_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateSaleInvoice = paths[typeof SALE_INVOICES_ROUTES.LIST]['post'];
|
||||||
|
type EditSaleInvoice = paths[typeof SALE_INVOICES_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteSaleInvoice = paths[typeof SALE_INVOICES_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
export type SaleInvoicesListResponse = GetSaleInvoices['responses'][200]['content']['application/json'];
|
||||||
|
export type SaleInvoice = GetSaleInvoice['responses'][200]['content']['application/json'];
|
||||||
|
export type CreateSaleInvoiceBody = CreateSaleInvoice['requestBody']['content']['application/json'];
|
||||||
|
export type EditSaleInvoiceBody = EditSaleInvoice['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchSaleInvoices(fetcher: ApiFetcher): Promise<SaleInvoicesListResponse> {
|
||||||
|
const get = fetcher.path(SALE_INVOICES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchSaleInvoice(fetcher: ApiFetcher, id: number): Promise<SaleInvoice> {
|
||||||
|
const get = fetcher.path(SALE_INVOICES_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createSaleInvoice(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateSaleInvoiceBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(SALE_INVOICES_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editSaleInvoice(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditSaleInvoiceBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(SALE_INVOICES_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteSaleInvoice(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(SALE_INVOICES_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const SALE_RECEIPTS_ROUTES = {
|
||||||
|
LIST: '/api/sale-receipts',
|
||||||
|
BY_ID: '/api/sale-receipts/{id}',
|
||||||
|
STATE: '/api/sale-receipts/state',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/sale-receipts/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/sale-receipts/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetSaleReceipts = paths[typeof SALE_RECEIPTS_ROUTES.LIST]['get'];
|
||||||
|
type GetSaleReceipt = paths[typeof SALE_RECEIPTS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateSaleReceipt = paths[typeof SALE_RECEIPTS_ROUTES.LIST]['post'];
|
||||||
|
type EditSaleReceipt = paths[typeof SALE_RECEIPTS_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteSaleReceipt = paths[typeof SALE_RECEIPTS_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetSaleReceipts200 = GetSaleReceipts['responses'][200];
|
||||||
|
type GetSaleReceipt200 = GetSaleReceipt['responses'][200];
|
||||||
|
export type SaleReceiptsListResponse = GetSaleReceipts200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type SaleReceipt = GetSaleReceipt200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateSaleReceiptBody = CreateSaleReceipt['requestBody']['content']['application/json'];
|
||||||
|
export type EditSaleReceiptBody = EditSaleReceipt['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchSaleReceipts(fetcher: ApiFetcher): Promise<SaleReceiptsListResponse> {
|
||||||
|
const get = fetcher.path(SALE_RECEIPTS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchSaleReceipt(fetcher: ApiFetcher, id: number): Promise<SaleReceipt> {
|
||||||
|
const get = fetcher.path(SALE_RECEIPTS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createSaleReceipt(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateSaleReceiptBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(SALE_RECEIPTS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editSaleReceipt(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditSaleReceiptBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(SALE_RECEIPTS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteSaleReceipt(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(SALE_RECEIPTS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const SETTINGS_ROUTES = {
|
||||||
|
GET_SAVE: '/api/settings',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetSettings = paths[typeof SETTINGS_ROUTES.GET_SAVE]['get'];
|
||||||
|
type SaveSettings = paths[typeof SETTINGS_ROUTES.GET_SAVE]['put'];
|
||||||
|
|
||||||
|
type GetSettings200 = GetSettings['responses'][200];
|
||||||
|
type SaveSettingsRequestBody = SaveSettings extends { requestBody: { content: { 'application/json': infer J } } } ? J : Record<string, unknown>;
|
||||||
|
export type SettingsResponse = GetSettings200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type SaveSettingsBody = SaveSettingsRequestBody;
|
||||||
|
|
||||||
|
export async function fetchSettings(fetcher: ApiFetcher): Promise<SettingsResponse> {
|
||||||
|
const get = fetcher.path(SETTINGS_ROUTES.GET_SAVE).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function saveSettings(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: SaveSettingsBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(SETTINGS_ROUTES.GET_SAVE).method('put').create();
|
||||||
|
await put(values);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const SUBSCRIPTION_ROUTES = {
|
||||||
|
LIST: '/api/subscription',
|
||||||
|
CHECKOUT_URL: '/api/subscription/lemon/checkout_url',
|
||||||
|
CANCEL: '/api/subscription/cancel',
|
||||||
|
RESUME: '/api/subscription/resume',
|
||||||
|
CHANGE: '/api/subscription/change',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetSubscriptions = paths[typeof SUBSCRIPTION_ROUTES.LIST]['get'];
|
||||||
|
|
||||||
|
type GetSubscriptions200 = GetSubscriptions['responses'][200];
|
||||||
|
export type SubscriptionsListResponse = GetSubscriptions200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchSubscriptions(fetcher: ApiFetcher): Promise<SubscriptionsListResponse> {
|
||||||
|
const get = fetcher.path(SUBSCRIPTION_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function cancelSubscription(fetcher: ApiFetcher): Promise<void> {
|
||||||
|
const post = fetcher.path(SUBSCRIPTION_ROUTES.CANCEL).method('post').create();
|
||||||
|
await post({});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resumeSubscription(fetcher: ApiFetcher): Promise<void> {
|
||||||
|
const post = fetcher.path(SUBSCRIPTION_ROUTES.RESUME).method('post').create();
|
||||||
|
await post({});
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const TRANSACTIONS_LOCKING_ROUTES = {
|
||||||
|
LOCK: '/api/transactions-locking/lock',
|
||||||
|
CANCEL_LOCK: '/api/transactions-locking/cancel-lock',
|
||||||
|
UNLOCK_PARTIAL: '/api/transactions-locking/unlock-partial',
|
||||||
|
CANCEL_UNLOCK_PARTIAL: '/api/transactions-locking/cancel-unlock-partial',
|
||||||
|
LIST: '/api/transactions-locking',
|
||||||
|
BY_MODULE: '/api/transactions-locking/{module}',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
export async function fetchTransactionsLocking(fetcher: ApiFetcher): Promise<void> {
|
||||||
|
const get = fetcher.path(TRANSACTIONS_LOCKING_ROUTES.LIST).method('get').create();
|
||||||
|
await get({});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchTransactionsLockingByModule(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
module: string
|
||||||
|
): Promise<void> {
|
||||||
|
const get = fetcher.path(TRANSACTIONS_LOCKING_ROUTES.BY_MODULE).method('get').create();
|
||||||
|
await get({ module });
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const USERS_ROUTES = {
|
||||||
|
LIST: '/api/users',
|
||||||
|
BY_ID: '/api/users/{id}',
|
||||||
|
ACTIVATE: '/api/users/{id}/activate',
|
||||||
|
INACTIVATE: '/api/users/{id}/inactivate',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetUsers = paths[typeof USERS_ROUTES.LIST]['get'];
|
||||||
|
type GetUser = paths[typeof USERS_ROUTES.BY_ID]['get'];
|
||||||
|
type EditUser = paths[typeof USERS_ROUTES.BY_ID]['put'];
|
||||||
|
|
||||||
|
type GetUsers200 = GetUsers['responses'][200];
|
||||||
|
type GetUser200 = GetUser['responses'][200];
|
||||||
|
export type UsersListResponse = GetUsers200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type User = GetUser200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type EditUserBody = EditUser['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export type GetUsersQuery = GetUsers['parameters']['query'];
|
||||||
|
|
||||||
|
export async function fetchUsers(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
query: GetUsersQuery = { page: 1, page_size: 20 }
|
||||||
|
): Promise<UsersListResponse> {
|
||||||
|
const get = fetcher.path(USERS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get(query);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchUser(fetcher: ApiFetcher, id: number): Promise<User> {
|
||||||
|
const get = fetcher.path(USERS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editUser(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditUserBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(USERS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteUser(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(USERS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activateUser(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const put = fetcher.path(USERS_ROUTES.ACTIVATE).method('put').create();
|
||||||
|
await (put as (params: { id: number }) => ReturnType<typeof put>)({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function inactivateUser(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const put = fetcher.path(USERS_ROUTES.INACTIVATE).method('put').create();
|
||||||
|
await (put as (params: { id: number }) => ReturnType<typeof put>)({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const VENDOR_CREDITS_ROUTES = {
|
||||||
|
LIST: '/api/vendor-credits',
|
||||||
|
BY_ID: '/api/vendor-credits/{id}',
|
||||||
|
OPEN: '/api/vendor-credits/{id}/open',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/vendor-credits/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/vendor-credits/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetVendorCredits = paths[typeof VENDOR_CREDITS_ROUTES.LIST]['get'];
|
||||||
|
type GetVendorCredit = paths[typeof VENDOR_CREDITS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateVendorCredit = paths[typeof VENDOR_CREDITS_ROUTES.LIST]['post'];
|
||||||
|
type EditVendorCredit = paths[typeof VENDOR_CREDITS_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteVendorCredit = paths[typeof VENDOR_CREDITS_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetVendorCredits200 = GetVendorCredits['responses'][200];
|
||||||
|
type GetVendorCredit200 = GetVendorCredit['responses'][200];
|
||||||
|
export type VendorCreditsListResponse = GetVendorCredits200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type VendorCredit = GetVendorCredit200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateVendorCreditBody = CreateVendorCredit['requestBody']['content']['application/json'];
|
||||||
|
export type EditVendorCreditBody = EditVendorCredit['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchVendorCredits(fetcher: ApiFetcher): Promise<VendorCreditsListResponse> {
|
||||||
|
const get = fetcher.path(VENDOR_CREDITS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchVendorCredit(fetcher: ApiFetcher, id: number): Promise<VendorCredit> {
|
||||||
|
const get = fetcher.path(VENDOR_CREDITS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createVendorCredit(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateVendorCreditBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(VENDOR_CREDITS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editVendorCredit(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditVendorCreditBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(VENDOR_CREDITS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteVendorCredit(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(VENDOR_CREDITS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function openVendorCredit(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const put = fetcher.path(VENDOR_CREDITS_ROUTES.OPEN).method('put').create();
|
||||||
|
await put({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const VENDORS_ROUTES = {
|
||||||
|
LIST: '/api/vendors',
|
||||||
|
BY_ID: '/api/vendors/{id}',
|
||||||
|
OPENING_BALANCE: '/api/vendors/{id}/opening-balance',
|
||||||
|
VALIDATE_BULK_DELETE: '/api/vendors/validate-bulk-delete',
|
||||||
|
BULK_DELETE: '/api/vendors/bulk-delete',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetVendors = paths[typeof VENDORS_ROUTES.LIST]['get'];
|
||||||
|
type GetVendor = paths[typeof VENDORS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateVendor = paths[typeof VENDORS_ROUTES.LIST]['post'];
|
||||||
|
type EditVendor = paths[typeof VENDORS_ROUTES.BY_ID]['put'];
|
||||||
|
type ValidateBulkDelete = paths[typeof VENDORS_ROUTES.VALIDATE_BULK_DELETE]['post'];
|
||||||
|
type BulkDelete = paths[typeof VENDORS_ROUTES.BULK_DELETE]['post'];
|
||||||
|
|
||||||
|
type GetVendors200 = GetVendors['responses'][200];
|
||||||
|
type GetVendor200 = GetVendor['responses'][200];
|
||||||
|
export type VendorsListResponse = GetVendors200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type Vendor = GetVendor200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateVendorBody = CreateVendor['requestBody']['content']['application/json'];
|
||||||
|
export type EditVendorBody = EditVendor['requestBody']['content']['application/json'];
|
||||||
|
export type ValidateBulkDeleteVendorsResponse = ValidateBulkDelete['responses'][200]['content']['application/json'];
|
||||||
|
export type BulkDeleteVendorsBody = BulkDelete['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchVendors(fetcher: ApiFetcher): Promise<VendorsListResponse> {
|
||||||
|
const get = fetcher.path(VENDORS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchVendor(fetcher: ApiFetcher, id: number): Promise<Vendor> {
|
||||||
|
const get = fetcher.path(VENDORS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createVendor(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateVendorBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(VENDORS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editVendor(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditVendorBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(VENDORS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteVendor(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(VENDORS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function validateBulkDeleteVendors(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: BulkDeleteVendorsBody
|
||||||
|
): Promise<ValidateBulkDeleteVendorsResponse> {
|
||||||
|
const validate = fetcher.path(VENDORS_ROUTES.VALIDATE_BULK_DELETE).method('post').create();
|
||||||
|
const { data } = await validate(body);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function bulkDeleteVendors(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
body: BulkDeleteVendorsBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(VENDORS_ROUTES.BULK_DELETE).method('post').create();
|
||||||
|
await post(body);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const VIEWS_ROUTES = {
|
||||||
|
RESOURCE: '/api/views/resource/{resourceModel}',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetResourceView = paths[typeof VIEWS_ROUTES.RESOURCE]['get'];
|
||||||
|
|
||||||
|
type GetResourceView200 = GetResourceView['responses'][200];
|
||||||
|
export type ResourceViewResponse = GetResourceView200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
|
||||||
|
export async function fetchResourceView(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
resourceModel: string
|
||||||
|
): Promise<ResourceViewResponse> {
|
||||||
|
const get = fetcher.path(VIEWS_ROUTES.RESOURCE).method('get').create();
|
||||||
|
const { data } = await get({ resourceModel });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const WAREHOUSE_TRANSFERS_ROUTES = {
|
||||||
|
LIST: '/api/warehouse-transfers',
|
||||||
|
BY_ID: '/api/warehouse-transfers/{id}',
|
||||||
|
INITIATE: '/api/warehouse-transfers/{id}/initiate',
|
||||||
|
TRANSFERRED: '/api/warehouse-transfers/{id}/transferred',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetWarehouseTransfers = paths[typeof WAREHOUSE_TRANSFERS_ROUTES.LIST]['get'];
|
||||||
|
type GetWarehouseTransfer = paths[typeof WAREHOUSE_TRANSFERS_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateWarehouseTransfer = paths[typeof WAREHOUSE_TRANSFERS_ROUTES.LIST]['post'];
|
||||||
|
type EditWarehouseTransfer = paths[typeof WAREHOUSE_TRANSFERS_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteWarehouseTransfer = paths[typeof WAREHOUSE_TRANSFERS_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
type GetWarehouseTransfers200 = GetWarehouseTransfers['responses'][200];
|
||||||
|
type GetWarehouseTransfer200 = GetWarehouseTransfer['responses'][200];
|
||||||
|
export type WarehouseTransfersListResponse = GetWarehouseTransfers200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type WarehouseTransfer = GetWarehouseTransfer200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
||||||
|
export type CreateBody = CreateWarehouseTransfer extends { requestBody: { content: { 'application/json': infer J } } } ? J : Record<string, unknown>;
|
||||||
|
type EditBody = EditWarehouseTransfer extends { requestBody: { content: { 'application/json': infer J } } } ? J : Record<string, unknown>;
|
||||||
|
export type CreateWarehouseTransferBody = CreateBody;
|
||||||
|
export type EditWarehouseTransferBody = EditBody;
|
||||||
|
|
||||||
|
export async function fetchWarehouseTransfers(fetcher: ApiFetcher): Promise<WarehouseTransfersListResponse> {
|
||||||
|
const get = fetcher.path(WAREHOUSE_TRANSFERS_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchWarehouseTransfer(fetcher: ApiFetcher, id: number): Promise<WarehouseTransfer> {
|
||||||
|
const get = fetcher.path(WAREHOUSE_TRANSFERS_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createWarehouseTransfer(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateWarehouseTransferBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(WAREHOUSE_TRANSFERS_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editWarehouseTransfer(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: number,
|
||||||
|
values: EditWarehouseTransferBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(WAREHOUSE_TRANSFERS_ROUTES.BY_ID).method('put').create();
|
||||||
|
await (put as unknown as (params: { id: number } & EditWarehouseTransferBody) => Promise<void>)({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteWarehouseTransfer(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const del = fetcher.path(WAREHOUSE_TRANSFERS_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await (del as unknown as (params: { id: number }) => Promise<void>)({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function initiateWarehouseTransfer(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const put = fetcher.path(WAREHOUSE_TRANSFERS_ROUTES.INITIATE).method('put').create();
|
||||||
|
await (put as unknown as (params: { id: number }) => Promise<void>)({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function transferredWarehouseTransfer(fetcher: ApiFetcher, id: number): Promise<void> {
|
||||||
|
const put = fetcher.path(WAREHOUSE_TRANSFERS_ROUTES.TRANSFERRED).method('put').create();
|
||||||
|
await (put as unknown as (params: { id: number }) => Promise<void>)({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import type { ApiFetcher } from './fetch-utils';
|
||||||
|
import type { paths } from './schema';
|
||||||
|
|
||||||
|
export const WAREHOUSES_ROUTES = {
|
||||||
|
LIST: '/api/warehouses',
|
||||||
|
BY_ID: '/api/warehouses/{id}',
|
||||||
|
ACTIVATE: '/api/warehouses/activate',
|
||||||
|
MARK_PRIMARY: '/api/warehouses/{id}/mark-primary',
|
||||||
|
} as const satisfies Record<string, keyof paths>;
|
||||||
|
|
||||||
|
type GetWarehouses = paths[typeof WAREHOUSES_ROUTES.LIST]['get'];
|
||||||
|
type GetWarehouse = paths[typeof WAREHOUSES_ROUTES.BY_ID]['get'];
|
||||||
|
type CreateWarehouse = paths[typeof WAREHOUSES_ROUTES.LIST]['post'];
|
||||||
|
type EditWarehouse = paths[typeof WAREHOUSES_ROUTES.BY_ID]['put'];
|
||||||
|
type DeleteWarehouse = paths[typeof WAREHOUSES_ROUTES.BY_ID]['delete'];
|
||||||
|
|
||||||
|
export type WarehousesListResponse = GetWarehouses['responses'][200]['content']['application/json'];
|
||||||
|
export type Warehouse = GetWarehouse['responses'][200]['content']['application/json'];
|
||||||
|
export type CreateWarehouseBody = CreateWarehouse['requestBody']['content']['application/json'];
|
||||||
|
export type EditWarehouseBody = EditWarehouse['requestBody']['content']['application/json'];
|
||||||
|
|
||||||
|
export async function fetchWarehouses(fetcher: ApiFetcher): Promise<WarehousesListResponse> {
|
||||||
|
const get = fetcher.path(WAREHOUSES_ROUTES.LIST).method('get').create();
|
||||||
|
const { data } = await get({});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchWarehouse(fetcher: ApiFetcher, id: string): Promise<Warehouse> {
|
||||||
|
const get = fetcher.path(WAREHOUSES_ROUTES.BY_ID).method('get').create();
|
||||||
|
const { data } = await get({ id });
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createWarehouse(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
values: CreateWarehouseBody
|
||||||
|
): Promise<void> {
|
||||||
|
const post = fetcher.path(WAREHOUSES_ROUTES.LIST).method('post').create();
|
||||||
|
await post(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editWarehouse(
|
||||||
|
fetcher: ApiFetcher,
|
||||||
|
id: string,
|
||||||
|
values: EditWarehouseBody
|
||||||
|
): Promise<void> {
|
||||||
|
const put = fetcher.path(WAREHOUSES_ROUTES.BY_ID).method('put').create();
|
||||||
|
await put({ id, ...values });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteWarehouse(fetcher: ApiFetcher, id: string): Promise<void> {
|
||||||
|
const del = fetcher.path(WAREHOUSES_ROUTES.BY_ID).method('delete').create();
|
||||||
|
await del({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activateWarehouses(fetcher: ApiFetcher): Promise<void> {
|
||||||
|
const post = fetcher.path(WAREHOUSES_ROUTES.ACTIVATE).method('post').create();
|
||||||
|
await post({});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function markWarehousePrimary(fetcher: ApiFetcher, id: string): Promise<void> {
|
||||||
|
const put = fetcher.path(WAREHOUSES_ROUTES.MARK_PRIMARY).method('put').create();
|
||||||
|
await put({ id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"outDir": "dist",
|
||||||
|
"declaration": true,
|
||||||
|
"declarationDir": "dist",
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user