Skip to content

Commit

Permalink
feat(server): migrate interfaces from server package to backend libra…
Browse files Browse the repository at this point in the history
…ry (#9)
  • Loading branch information
benpsnyder authored May 14, 2024
1 parent b6db2c7 commit 6966451
Show file tree
Hide file tree
Showing 906 changed files with 1,475 additions and 1,298 deletions.
31 changes: 0 additions & 31 deletions libs/backend/.swcrc

This file was deleted.

8 changes: 4 additions & 4 deletions libs/backend/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# bigcapital-libs-backend
# mylib

This library was generated with [Nx](https://nx.dev).
This library was generated with [@nx-bun/nx](https://github.com/jordan-hall/nx-bun)

## Building

Run `nx build bigcapital-libs-backend` to build the library.
Run `nx build mylib` to build the library.

## Running unit tests

Run `nx test bigcapital-libs-backend` to execute the unit tests via [Jest](https://jestjs.io).
Run `nx test mylib` to execute the unit tests via [bun test](https://bun.sh/docs/cli/test).
15 changes: 15 additions & 0 deletions libs/backend/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../../node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["../../biome.json"],
"linter": {
"enabled": true,
"rules": {
"style": {
"useImportType": "error"
},
"correctness": {
"noUnusedImports": "error"
}
}
}
}
15 changes: 0 additions & 15 deletions libs/backend/jest.config.ts

This file was deleted.

8 changes: 0 additions & 8 deletions libs/backend/package.json

This file was deleted.

30 changes: 23 additions & 7 deletions libs/backend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,37 @@
"tags": ["stack:edge", "lang:typescript", "framework:agnostic", "ecosystem:shared", "domain:shared", "type:domain"],
"targets": {
"build": {
"executor": "@nx/js:swc",
"executor": "@nx-bun/nx:build",
"options": {
"assets": ["libs/backend/*.md"],
"main": "libs/backend/src/index.ts",
"bun": true,
"entrypoints": ["libs/backend/src/index.ts"],
"outputPath": "dist/libs/backend",
"smol": false,
"tsConfig": "libs/backend/tsconfig.lib.json"
},
"outputs": ["{options.outputPath}"]
},
"format": {
"executor": "nx:run-commands",
"options": {
"commands": ["cd libs/backend && bunx @biomejs/biome format --write ./"],
"parallel": false
}
},
"lint": {
"executor": "nx:run-commands",
"options": {
"commands": ["cd libs/backend && bunx @biomejs/biome lint --apply ./"],
"parallel": false
}
},
"test": {
"executor": "@nx/jest:jest",
"executor": "@nx-bun/nx:test",
"options": {
"jestConfig": "libs/backend/jest.config.ts"
},
"outputs": ["{workspaceRoot}/coverage/libs/backend"]
"bail": true,
"bun": false,
"smol": false
}
}
}
}
1 change: 1 addition & 0 deletions libs/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './lib/interfaces';
export * from './lib/backend';
export * from './lib/models';
export * from './lib/enums';
10 changes: 6 additions & 4 deletions libs/backend/src/lib/backend.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { edgeSharedDomain } from './bigcapital-libs-backend';
import { mylib } from './mylib';

describe('edgeSharedDomain', () => {
it('should work', () => {
expect(edgeSharedDomain()).toEqual('bigcapital-libs-backend');
import { describe, expect, test } from 'bun:test';

describe('mylib', () => {
test('should work', () => {
expect(mylib()).toEqual('mylib');
});
});
7 changes: 2 additions & 5 deletions libs/backend/src/lib/backend.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
export function edgeSharedDomain(): string {
return 'bigcapital-libs-backend';
export function mylib(): string {
return 'mylib';
}
149 changes: 149 additions & 0 deletions libs/backend/src/lib/interfaces/Account.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import type { Knex } from 'knex';
import type { IDynamicListFilter } from './DynamicFilter';

export interface IAccountCreateDTO extends IAccountDTO {
currencyCode?: string;
plaidAccountId?: string;
}

export interface IAccountDTO {
name: string;
code: string;
Expand All @@ -8,3 +16,144 @@ export interface IAccountDTO {
bankBalance?: number;
accountMask?: string;
}

export interface IAccountEditDTO extends IAccountDTO {}

export interface IAccount {
id: number;
name: string;
slug: string;
code: string;
index: number;
description: string;
accountType: string;
parentAccountId: number;
active: boolean;
predefined: boolean;
amount: number;
currencyCode: string;
transactions?: any[];
type?: any[];
accountNormal: string;
accountParentType: string;
bankBalance: string;
}

export enum AccountNormal {
DEBIT = 'debit',
CREDIT = 'credit',
}

export interface IAccountsTransactionsFilter {
accountId?: number;
limit?: number;
}

export interface IAccountTransaction {
id?: number;

credit: number;
debit: number;
currencyCode: string;
exchangeRate: number;

accountId: number;
contactId?: number | null;
date: string | Date;

referenceType: string;
referenceTypeFormatted: string;
referenceId: number;

referenceNumber?: string;
transactionNumber?: string;

note?: string;

index: number;
indexGroup?: number;

costable?: boolean;

userId?: number;
itemId?: number;
branchId?: number;
projectId?: number;

account?: IAccount;

taxRateId?: number;
taxRate?: number;
}
export interface IAccountResponse extends IAccount {}

export enum IAccountsStructureType {
Tree = 'tree',
Flat = 'flat',
}

export interface IAccountsFilter extends IDynamicListFilter {
stringifiedFilterRoles: string;
onlyInactive: boolean;
structure?: IAccountsStructureType;
}

export interface IAccountType {
label: string;
key: string;
normal: string;
rootType: string;
childType: string;
balanceSheet: boolean;
incomeSheet: boolean;
}

export interface IAccountsTypesService {
getAccountsTypes(tenantId: number): Promise<IAccountType>;
}

export interface IAccountEventCreatingPayload {
tenantId: number;
accountDTO: any;
trx: Knex.Transaction;
}
export interface IAccountEventCreatedPayload {
tenantId: number;
account: IAccount;
accountId: number;
trx: Knex.Transaction;
}

export interface IAccountEventEditedPayload {
tenantId: number;
account: IAccount;
oldAccount: IAccount;
trx: Knex.Transaction;
}

export interface IAccountEventDeletedPayload {
tenantId: number;
accountId: number;
oldAccount: IAccount;
trx: Knex.Transaction;
}

export interface IAccountEventDeletePayload {
trx: Knex.Transaction;
oldAccount: IAccount;
tenantId: number;
}

export interface IAccountEventActivatedPayload {
tenantId: number;
accountId: number;
trx: Knex.Transaction;
}

export enum AccountAction {
CREATE = 'Create',
EDIT = 'Edit',
DELETE = 'Delete',
VIEW = 'View',
TransactionsLocking = 'TransactionsLocking',
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Knex } from 'knex';
import type { IDynamicListFilterDTO } from './DynamicFilter';
import type { IDynamicListFilter } from './DynamicFilter';
import type { IItemEntry, IItemEntryDTO } from './ItemEntry';
import type { IBillLandedCost } from './LandedCost';

Expand Down Expand Up @@ -92,7 +92,7 @@ export interface IBill {
totalLocal: number;
}

export interface IBillsFilter extends IDynamicListFilterDTO {
export interface IBillsFilter extends IDynamicListFilter {
stringifiedFilterRoles?: string;
page: number;
pageSize: number;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ISystemUser } from '@bigcapital/server/interfaces';
import type { Knex } from 'knex';
import type { ISystemUser } from './';
import type { IFilterRole } from './DynamicFilter';

export enum ContactService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IDynamicListFilter, IItemEntry } from '@bigcapital/server/interfaces';
import type { Knex } from 'knex';
import type { IDynamicListFilter, IItemEntry } from './';
import type { ILedgerEntry } from './Ledger';

export interface ICreditNoteEntryNewDTO {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface IInventoryCostMethod {
export interface IInventoryCostMethod {
computeItemsCost(fromDate: Date): void;
storeInventoryLotsCost(transactions: any[]): void;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AbilitySubject } from '@bigcapital/server/interfaces';
import type { IFilterRole } from '@bigcapital/server/interfaces/DynamicFilter';
import type { IFilterRole } from '@bigcapital/libs-backend';
import type { Knex } from 'knex';
import type { AbilitySubject } from './';

export interface IItem {
id: number;
Expand Down Expand Up @@ -79,7 +79,7 @@ export interface IItemsService {
itemsList(tenantId: number, itemsFilter: IItemsFilter): Promise<{ items: IItem[] }>;
}

export interface IItemsFilter extends IDynamicListFilterDTO {
export interface IItemsFilter extends IDynamicListFilter {
stringifiedFilterRoles?: string;
page: number;
pageSize: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type Knex from 'knex';
import type { IDynamicListFilterDTO } from './DynamicFilter';
import type { IDynamicListFilter } from './DynamicFilter';
import type { ISystemUser } from './User';

export interface IItemCategory {
Expand Down Expand Up @@ -28,7 +28,7 @@ export interface IItemCategoryOTD {
costMethod?: string;
}

export interface IItemCategoriesFilter extends IDynamicListFilterDTO {
export interface IItemCategoriesFilter extends IDynamicListFilter {
stringifiedFilterRoles?: string;
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6966451

Please sign in to comment.