ohadakit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +385 -0
- package/dist/browser/ohadakit.iife.js +3 -0
- package/dist/browser/ohadakit.umd.js +3 -0
- package/dist/cjs/index.js +6456 -0
- package/dist/esm/index.js +6456 -0
- package/dist/types/AccountBook.d.ts +58 -0
- package/dist/types/LedgerEngine.d.ts +45 -0
- package/dist/types/core/Account.d.ts +49 -0
- package/dist/types/core/AccountIndex.d.ts +31 -0
- package/dist/types/core/AccountRegistry.d.ts +39 -0
- package/dist/types/core/types.d.ts +127 -0
- package/dist/types/custom/CustomAccountIndex.d.ts +28 -0
- package/dist/types/custom/CustomAccountManager.d.ts +44 -0
- package/dist/types/custom/CustomAccountValidator.d.ts +23 -0
- package/dist/types/custom/errors.d.ts +37 -0
- package/dist/types/custom/index.d.ts +8 -0
- package/dist/types/custom/types.d.ts +52 -0
- package/dist/types/data/ohada/accounts-flat.d.ts +27 -0
- package/dist/types/data/ohada/class-1-ressources.d.ts +3 -0
- package/dist/types/data/ohada/class-2-immobilisations.d.ts +3 -0
- package/dist/types/data/ohada/class-3-stocks.d.ts +3 -0
- package/dist/types/data/ohada/class-4-tiers.d.ts +3 -0
- package/dist/types/data/ohada/class-5-tresorerie.d.ts +3 -0
- package/dist/types/data/ohada/class-6-charges.d.ts +3 -0
- package/dist/types/data/ohada/class-7-produits.d.ts +3 -0
- package/dist/types/data/ohada/class-8-hao.d.ts +3 -0
- package/dist/types/data/ohada/class-9-engagements.d.ts +3 -0
- package/dist/types/data/ohada/classes.d.ts +3 -0
- package/dist/types/data/ohada/index.d.ts +26 -0
- package/dist/types/data/ohada/types.d.ts +39 -0
- package/dist/types/data/ohada-accounts.d.ts +6 -0
- package/dist/types/export/Exporter.d.ts +11 -0
- package/dist/types/i18n/TranslationService.d.ts +15 -0
- package/dist/types/i18n/account-names.d.ts +3 -0
- package/dist/types/i18n/index.d.ts +4 -0
- package/dist/types/i18n/types.d.ts +13 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/query/QueryEngine.d.ts +30 -0
- package/dist/types/storage/LocalStorage.d.ts +14 -0
- package/dist/types/storage/MemoryStorage.d.ts +11 -0
- package/dist/types/validation/errors.d.ts +43 -0
- package/dist/types/validation/validators.d.ts +14 -0
- package/package.json +75 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Account } from './core/Account';
|
|
2
|
+
import { type AccountRegistry } from './core/AccountRegistry';
|
|
3
|
+
import { QueryBuilder } from './query/QueryEngine';
|
|
4
|
+
import { CustomAccountManager } from './custom/CustomAccountManager';
|
|
5
|
+
import { TranslationService } from './i18n/TranslationService';
|
|
6
|
+
import type { Result, StorageAdapter, AccountBookOptions, AccountBookSnapshot, AccountBookStats, JsonExportOptions, CsvExportOptions, OhadaLocale } from './core/types';
|
|
7
|
+
import type { CustomAccountInput, LabelOverride } from './custom/types';
|
|
8
|
+
export declare class AccountBook {
|
|
9
|
+
readonly registry: AccountRegistry;
|
|
10
|
+
readonly customManager: CustomAccountManager;
|
|
11
|
+
readonly i18n: TranslationService;
|
|
12
|
+
private readonly storage;
|
|
13
|
+
private readonly storagePrefix;
|
|
14
|
+
private readonly notesCache;
|
|
15
|
+
private notesCacheLoaded;
|
|
16
|
+
private initialized;
|
|
17
|
+
constructor(options: AccountBookOptions);
|
|
18
|
+
initialize(): Promise<void>;
|
|
19
|
+
isInitialized(): boolean;
|
|
20
|
+
getAccount(code: string): Result<Account>;
|
|
21
|
+
getAccountOrNull(code: string): Account | null;
|
|
22
|
+
getAccountOrThrow(code: string): Account;
|
|
23
|
+
has(code: string): boolean;
|
|
24
|
+
getAllAccounts(): Account[];
|
|
25
|
+
query(): QueryBuilder;
|
|
26
|
+
createAccount(input: CustomAccountInput): Promise<Result<Account>>;
|
|
27
|
+
deleteAccount(code: string): Promise<Result<void>>;
|
|
28
|
+
updateLabel(code: string, newLabel: string): Promise<Result<Account>>;
|
|
29
|
+
getCustomAccounts(): Account[];
|
|
30
|
+
getLabelOverrides(): LabelOverride[];
|
|
31
|
+
setNote(code: string, note: string): Promise<void>;
|
|
32
|
+
getNote(code: string): Promise<string | null>;
|
|
33
|
+
deleteNote(code: string): Promise<void>;
|
|
34
|
+
getAllNotes(): Promise<Map<string, string>>;
|
|
35
|
+
clearAllNotes(): Promise<void>;
|
|
36
|
+
getLocalizedName(code: string): string | null;
|
|
37
|
+
getLocale(): OhadaLocale;
|
|
38
|
+
setLocale(locale: OhadaLocale): void;
|
|
39
|
+
getAvailableLocales(): OhadaLocale[];
|
|
40
|
+
exportToJSON(options?: JsonExportOptions): string;
|
|
41
|
+
exportToCSV(options?: CsvExportOptions): string;
|
|
42
|
+
exportClass(classCode: string, format: 'json', options?: JsonExportOptions): string;
|
|
43
|
+
exportClass(classCode: string, format: 'csv', options?: CsvExportOptions): string;
|
|
44
|
+
snapshot(): Promise<AccountBookSnapshot>;
|
|
45
|
+
restore(snap: AccountBookSnapshot): Promise<Result<void>>;
|
|
46
|
+
getStats(): Promise<AccountBookStats>;
|
|
47
|
+
private ensureInitialized;
|
|
48
|
+
private notesKey;
|
|
49
|
+
private loadNotesCache;
|
|
50
|
+
private validateSnapshotShape;
|
|
51
|
+
}
|
|
52
|
+
export interface CreateAccountBookOptions {
|
|
53
|
+
storage?: StorageAdapter;
|
|
54
|
+
locale?: OhadaLocale;
|
|
55
|
+
storagePrefix?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function createAccountBook(options?: CreateAccountBookOptions): AccountBook;
|
|
58
|
+
//# sourceMappingURL=AccountBook.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Account } from './core/Account';
|
|
2
|
+
import { AccountRegistry } from './core/AccountRegistry';
|
|
3
|
+
import { QueryBuilder } from './query/QueryEngine';
|
|
4
|
+
import type { Result, LedgerEngineOptions, StorageAdapter, RegistryStats, JsonExportOptions, CsvExportOptions, OhadaLocale } from './core/types';
|
|
5
|
+
import { TranslationService } from './i18n/TranslationService';
|
|
6
|
+
export declare class LedgerEngine {
|
|
7
|
+
readonly registry: AccountRegistry;
|
|
8
|
+
readonly storage: StorageAdapter;
|
|
9
|
+
readonly i18n: TranslationService;
|
|
10
|
+
constructor(options?: LedgerEngineOptions);
|
|
11
|
+
get(code: string): Result<Account>;
|
|
12
|
+
getOrThrow(code: string): Account;
|
|
13
|
+
getOrNull(code: string): Account | null;
|
|
14
|
+
query(): QueryBuilder;
|
|
15
|
+
validateBatch(codes: string[]): {
|
|
16
|
+
valid: Array<{
|
|
17
|
+
code: string;
|
|
18
|
+
account: Account;
|
|
19
|
+
}>;
|
|
20
|
+
invalid: Array<{
|
|
21
|
+
code: string;
|
|
22
|
+
error: Error;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
getNote(code: string): Promise<string | null>;
|
|
26
|
+
setNote(code: string, note: string): Promise<void>;
|
|
27
|
+
deleteNote(code: string): Promise<void>;
|
|
28
|
+
getAllNotes(): Promise<Map<string, string>>;
|
|
29
|
+
clearAllNotes(): Promise<void>;
|
|
30
|
+
hasNote(code: string): Promise<boolean>;
|
|
31
|
+
export(format: 'json', options?: JsonExportOptions): string;
|
|
32
|
+
export(format: 'csv', options?: CsvExportOptions): string;
|
|
33
|
+
exportToJSON(options?: JsonExportOptions): string;
|
|
34
|
+
exportToCSV(options?: CsvExportOptions): string;
|
|
35
|
+
exportClass(classCode: string, format: 'json', options?: JsonExportOptions): string;
|
|
36
|
+
exportClass(classCode: string, format: 'csv', options?: CsvExportOptions): string;
|
|
37
|
+
getLocalizedName(code: string): string | null;
|
|
38
|
+
getLocale(): OhadaLocale;
|
|
39
|
+
setLocale(locale: OhadaLocale): void;
|
|
40
|
+
getAvailableLocales(): OhadaLocale[];
|
|
41
|
+
getStats(): RegistryStats;
|
|
42
|
+
}
|
|
43
|
+
export declare function createLedgerEngine(options?: LedgerEngineOptions): LedgerEngine;
|
|
44
|
+
export declare function getDefaultLedgerEngine(): LedgerEngine;
|
|
45
|
+
//# sourceMappingURL=LedgerEngine.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AccountCode, RawAccountData, AccountJSON, AccountMetadata, ClassCode } from './types';
|
|
2
|
+
export declare class Account {
|
|
3
|
+
readonly code: AccountCode;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly level: 1 | 2 | 3 | 4;
|
|
6
|
+
readonly classCode: ClassCode;
|
|
7
|
+
readonly parentCode?: AccountCode;
|
|
8
|
+
readonly metadata?: AccountMetadata;
|
|
9
|
+
private _registry?;
|
|
10
|
+
private _parent?;
|
|
11
|
+
private _children?;
|
|
12
|
+
private _ancestors?;
|
|
13
|
+
private _siblings?;
|
|
14
|
+
private _path?;
|
|
15
|
+
private _pathString?;
|
|
16
|
+
private _pathCodes?;
|
|
17
|
+
constructor(data: RawAccountData, metadata?: AccountMetadata);
|
|
18
|
+
_setRegistry(registry: AccountRegistry): void;
|
|
19
|
+
get parent(): Account | null;
|
|
20
|
+
get children(): Account[];
|
|
21
|
+
get ancestors(): Account[];
|
|
22
|
+
get siblings(): Account[];
|
|
23
|
+
get path(): Account[];
|
|
24
|
+
get pathString(): string;
|
|
25
|
+
get pathCodes(): string[];
|
|
26
|
+
get classAccount(): Account | null;
|
|
27
|
+
get isLeaf(): boolean;
|
|
28
|
+
get isRoot(): boolean;
|
|
29
|
+
isDescendantOf(code: string): boolean;
|
|
30
|
+
isAncestorOf(code: string): boolean;
|
|
31
|
+
isSiblingOf(code: string): boolean;
|
|
32
|
+
get depth(): number;
|
|
33
|
+
getDescendants(): Account[];
|
|
34
|
+
getDescendantsAtLevel(relativeLevel: number): Account[];
|
|
35
|
+
toJSON(): AccountJSON;
|
|
36
|
+
toRawData(): RawAccountData;
|
|
37
|
+
toString(): string;
|
|
38
|
+
toDetailedString(): string;
|
|
39
|
+
static fromRawData(data: RawAccountData, metadata?: AccountMetadata): Account;
|
|
40
|
+
static fromJSON(json: AccountJSON): Account;
|
|
41
|
+
}
|
|
42
|
+
export declare function isAccount(value: unknown): value is Account;
|
|
43
|
+
interface AccountRegistry {
|
|
44
|
+
getByCode(code: AccountCode): Account | null;
|
|
45
|
+
getChildren(code: AccountCode): Account[];
|
|
46
|
+
getByLevel(level: number): Account[];
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=Account.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Account } from './Account';
|
|
2
|
+
export declare class AccountIndex {
|
|
3
|
+
private byCode;
|
|
4
|
+
private byClass;
|
|
5
|
+
private byLevel;
|
|
6
|
+
private byParent;
|
|
7
|
+
private codeTrie;
|
|
8
|
+
private nameIndex;
|
|
9
|
+
constructor(accounts?: Account[]);
|
|
10
|
+
private addAccount;
|
|
11
|
+
private indexAccountName;
|
|
12
|
+
get(code: string): Account | null;
|
|
13
|
+
has(code: string): boolean;
|
|
14
|
+
getByClass(classCode: string): Account[];
|
|
15
|
+
getByLevel(level: number): Account[];
|
|
16
|
+
getChildren(code: string): Account[];
|
|
17
|
+
getAll(): Account[];
|
|
18
|
+
searchByPrefix(prefix: string): Account[];
|
|
19
|
+
searchByName(query: string, options?: {
|
|
20
|
+
limit?: number;
|
|
21
|
+
}): Account[];
|
|
22
|
+
searchByNameFuzzy(query: string, threshold?: number, limit?: number): Account[];
|
|
23
|
+
private fuzzyMatch;
|
|
24
|
+
private levenshteinDistance;
|
|
25
|
+
get size(): number;
|
|
26
|
+
getClassCounts(): Map<string, number>;
|
|
27
|
+
getLevelCounts(): Map<number, number>;
|
|
28
|
+
clear(): void;
|
|
29
|
+
rebuild(accounts: Account[]): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=AccountIndex.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Account } from './Account';
|
|
2
|
+
import type { AccountCode, RawAccountData, RegistryStats, OhadaClass } from './types';
|
|
3
|
+
export declare class AccountRegistry {
|
|
4
|
+
private accounts;
|
|
5
|
+
private index;
|
|
6
|
+
private initialized;
|
|
7
|
+
constructor(accountsData?: RawAccountData[]);
|
|
8
|
+
getByCode(code: string): Account | null;
|
|
9
|
+
has(code: string): boolean;
|
|
10
|
+
getByClass(classCode: string): Account[];
|
|
11
|
+
getByLevel(level: number): Account[];
|
|
12
|
+
getChildren(code: string | AccountCode): Account[];
|
|
13
|
+
getAll(): Account[];
|
|
14
|
+
searchByPrefix(prefix: string): Account[];
|
|
15
|
+
searchByName(query: string, options?: {
|
|
16
|
+
limit?: number;
|
|
17
|
+
}): Account[];
|
|
18
|
+
searchByNameFuzzy(query: string, threshold?: number, limit?: number): Account[];
|
|
19
|
+
getClassMetadata(classCode: string): OhadaClass | null;
|
|
20
|
+
getClassRoot(classCode: string): Account | null;
|
|
21
|
+
getMainAccounts(classCode: string): Account[];
|
|
22
|
+
getStats(): RegistryStats;
|
|
23
|
+
get size(): number;
|
|
24
|
+
get isInitialized(): boolean;
|
|
25
|
+
getLeafAccounts(): Account[];
|
|
26
|
+
getRootAccounts(): Account[];
|
|
27
|
+
getByLevelRange(minLevel: number, maxLevel: number): Account[];
|
|
28
|
+
getSubtree(code: string): Account[];
|
|
29
|
+
getSiblings(code: string): Account[];
|
|
30
|
+
getAncestors(code: string): Account[];
|
|
31
|
+
getPath(code: string): Account[];
|
|
32
|
+
validateIntegrity(): {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
errors: string[];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare function getDefaultRegistry(): AccountRegistry;
|
|
38
|
+
export declare function resetDefaultRegistry(): void;
|
|
39
|
+
//# sourceMappingURL=AccountRegistry.d.ts.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export type OhadaLocale = 'fr' | 'en' | 'pt' | 'es';
|
|
2
|
+
export type AccountCode = string & {
|
|
3
|
+
readonly __brand: 'AccountCode';
|
|
4
|
+
};
|
|
5
|
+
export type ClassCode = string & {
|
|
6
|
+
readonly __brand: 'ClassCode';
|
|
7
|
+
};
|
|
8
|
+
export type Result<T, E = Error> = {
|
|
9
|
+
ok: true;
|
|
10
|
+
data: T;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
error: E;
|
|
14
|
+
};
|
|
15
|
+
export declare function Ok<T, E = Error>(data: T): Result<T, E>;
|
|
16
|
+
export declare function Err<E = Error>(error: E): Result<never, E>;
|
|
17
|
+
export interface RawAccountData {
|
|
18
|
+
code: string;
|
|
19
|
+
name: string;
|
|
20
|
+
level: 1 | 2 | 3 | 4;
|
|
21
|
+
classCode: string;
|
|
22
|
+
parentCode?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AccountMetadata {
|
|
25
|
+
description?: string;
|
|
26
|
+
nameEn?: string;
|
|
27
|
+
descriptionEn?: string;
|
|
28
|
+
tags?: string[];
|
|
29
|
+
isCommon?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface AccountJSON {
|
|
32
|
+
code: string;
|
|
33
|
+
name: string;
|
|
34
|
+
level: number;
|
|
35
|
+
classCode: string;
|
|
36
|
+
parentCode?: string;
|
|
37
|
+
path: string[];
|
|
38
|
+
pathString: string;
|
|
39
|
+
metadata?: AccountMetadata;
|
|
40
|
+
}
|
|
41
|
+
export interface OhadaClass {
|
|
42
|
+
code: ClassCode;
|
|
43
|
+
name: string;
|
|
44
|
+
nameEn: string;
|
|
45
|
+
description: string;
|
|
46
|
+
descriptionEn: string;
|
|
47
|
+
}
|
|
48
|
+
export interface QueryFilter {
|
|
49
|
+
class?: string | string[];
|
|
50
|
+
level?: number | number[];
|
|
51
|
+
parent?: string;
|
|
52
|
+
nameContains?: string;
|
|
53
|
+
codePattern?: RegExp;
|
|
54
|
+
predicate?: (account: any) => boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface SearchOptions {
|
|
57
|
+
fuzzy?: boolean;
|
|
58
|
+
threshold?: number;
|
|
59
|
+
limit?: number;
|
|
60
|
+
caseSensitive?: boolean;
|
|
61
|
+
fields?: ('code' | 'name')[];
|
|
62
|
+
}
|
|
63
|
+
export interface SortOptions {
|
|
64
|
+
by: 'code' | 'name' | 'level';
|
|
65
|
+
direction: 'asc' | 'desc';
|
|
66
|
+
}
|
|
67
|
+
export interface RegistryStats {
|
|
68
|
+
total: number;
|
|
69
|
+
byClass: Record<string, number>;
|
|
70
|
+
byLevel: Record<number, number>;
|
|
71
|
+
mainAccounts: number;
|
|
72
|
+
subAccounts: number;
|
|
73
|
+
detailAccounts: number;
|
|
74
|
+
}
|
|
75
|
+
export type ExportFormat = 'json' | 'csv';
|
|
76
|
+
export type JsonStructure = 'flat' | 'hierarchical';
|
|
77
|
+
export interface JsonExportOptions {
|
|
78
|
+
structure?: JsonStructure;
|
|
79
|
+
pretty?: boolean;
|
|
80
|
+
includeNotes?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export interface CsvExportOptions {
|
|
83
|
+
delimiter?: string;
|
|
84
|
+
includeHeader?: boolean;
|
|
85
|
+
columns?: string[];
|
|
86
|
+
includeNotes?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export type ExportOptions = JsonExportOptions | CsvExportOptions;
|
|
89
|
+
export interface StorageAdapter {
|
|
90
|
+
get(key: string): Promise<string | null>;
|
|
91
|
+
set(key: string, value: string): Promise<void>;
|
|
92
|
+
delete(key: string): Promise<void>;
|
|
93
|
+
getAll(): Promise<Map<string, string>>;
|
|
94
|
+
clear(): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
export interface LedgerEngineOptions {
|
|
97
|
+
storage?: StorageAdapter;
|
|
98
|
+
locale?: OhadaLocale;
|
|
99
|
+
}
|
|
100
|
+
export declare function isClassCode(value: unknown): value is ClassCode;
|
|
101
|
+
export declare function isOk<T, E>(result: Result<T, E>): result is {
|
|
102
|
+
ok: true;
|
|
103
|
+
data: T;
|
|
104
|
+
};
|
|
105
|
+
export declare function isErr<T, E>(result: Result<T, E>): result is {
|
|
106
|
+
ok: false;
|
|
107
|
+
error: E;
|
|
108
|
+
};
|
|
109
|
+
export interface AccountBookOptions {
|
|
110
|
+
storage: StorageAdapter;
|
|
111
|
+
locale?: OhadaLocale;
|
|
112
|
+
storagePrefix?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface AccountBookSnapshot {
|
|
115
|
+
version: number;
|
|
116
|
+
timestamp: string;
|
|
117
|
+
locale: OhadaLocale;
|
|
118
|
+
customAccounts: import('../custom/types').CustomAccountData[];
|
|
119
|
+
labelOverrides: import('../custom/types').LabelOverride[];
|
|
120
|
+
notes: Record<string, string>;
|
|
121
|
+
}
|
|
122
|
+
export interface AccountBookStats extends RegistryStats {
|
|
123
|
+
customAccountCount: number;
|
|
124
|
+
labelOverrideCount: number;
|
|
125
|
+
noteCount: number;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CustomAccountData } from './types';
|
|
2
|
+
export declare class CustomAccountIndex {
|
|
3
|
+
private byCode;
|
|
4
|
+
private byClass;
|
|
5
|
+
private byParent;
|
|
6
|
+
constructor();
|
|
7
|
+
add(account: CustomAccountData): void;
|
|
8
|
+
remove(code: string): boolean;
|
|
9
|
+
update(account: CustomAccountData): void;
|
|
10
|
+
get(code: string): CustomAccountData | null;
|
|
11
|
+
has(code: string): boolean;
|
|
12
|
+
getAll(): CustomAccountData[];
|
|
13
|
+
getAllCodes(): string[];
|
|
14
|
+
getByClass(classCode: string): CustomAccountData[];
|
|
15
|
+
getByParent(parentCode: string): CustomAccountData[];
|
|
16
|
+
getChildrenCodes(parentCode: string): string[];
|
|
17
|
+
searchByName(query: string): CustomAccountData[];
|
|
18
|
+
searchByPrefix(prefix: string): CustomAccountData[];
|
|
19
|
+
get size(): number;
|
|
20
|
+
clear(): void;
|
|
21
|
+
rebuild(accounts: CustomAccountData[]): void;
|
|
22
|
+
getStats(): {
|
|
23
|
+
total: number;
|
|
24
|
+
byClass: Record<string, number>;
|
|
25
|
+
};
|
|
26
|
+
toMap(): Map<string, CustomAccountData>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=CustomAccountIndex.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Account } from '../core/Account';
|
|
2
|
+
import { AccountRegistry } from '../core/AccountRegistry';
|
|
3
|
+
import type { StorageAdapter } from '../core/types';
|
|
4
|
+
import type { CustomAccountInput, CustomAccountData, CustomAccountManagerOptions, LabelOverride, CreateAccountResult, UpdateLabelResult, DeleteAccountResult, CustomAccountStats } from './types';
|
|
5
|
+
export declare class CustomAccountManager {
|
|
6
|
+
private readonly baseRegistry;
|
|
7
|
+
private readonly storage;
|
|
8
|
+
private readonly storagePrefix;
|
|
9
|
+
private readonly customIndex;
|
|
10
|
+
private readonly labelOverrides;
|
|
11
|
+
private readonly validator;
|
|
12
|
+
private initialized;
|
|
13
|
+
constructor(options: CustomAccountManagerOptions);
|
|
14
|
+
initialize(): Promise<void>;
|
|
15
|
+
isInitialized(): boolean;
|
|
16
|
+
createAccount(input: CustomAccountInput): Promise<CreateAccountResult>;
|
|
17
|
+
deleteCustomAccount(code: string): Promise<DeleteAccountResult>;
|
|
18
|
+
updateLabel(code: string, newLabel: string): Promise<UpdateLabelResult>;
|
|
19
|
+
getOriginalLabel(code: string): string | null;
|
|
20
|
+
hasLabelOverride(code: string): boolean;
|
|
21
|
+
getByCode(code: string): Account | null;
|
|
22
|
+
has(code: string): boolean;
|
|
23
|
+
getAll(): Account[];
|
|
24
|
+
getCustomAccounts(): Account[];
|
|
25
|
+
getCustomAccountData(): CustomAccountData[];
|
|
26
|
+
getLabelOverrides(): LabelOverride[];
|
|
27
|
+
getChildren(code: string): Account[];
|
|
28
|
+
getByClass(classCode: string): Account[];
|
|
29
|
+
searchByName(query: string): Account[];
|
|
30
|
+
searchByPrefix(prefix: string): Account[];
|
|
31
|
+
save(): Promise<void>;
|
|
32
|
+
load(): Promise<void>;
|
|
33
|
+
clear(): Promise<void>;
|
|
34
|
+
getStats(): CustomAccountStats;
|
|
35
|
+
getTotalCount(): number;
|
|
36
|
+
getBaseRegistry(): AccountRegistry;
|
|
37
|
+
getStorage(): StorageAdapter;
|
|
38
|
+
private applyLabelOverride;
|
|
39
|
+
private ensureInitialized;
|
|
40
|
+
private getStorageKey;
|
|
41
|
+
private createAccountInstance;
|
|
42
|
+
private createAccountWithCustomLabel;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=CustomAccountManager.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AccountRegistry } from '../core/AccountRegistry';
|
|
2
|
+
import type { Account } from '../core/Account';
|
|
3
|
+
import type { Result } from '../core/types';
|
|
4
|
+
import type { CustomAccountInput, CustomAccountData } from './types';
|
|
5
|
+
import { CannotModifyMainAccountError, CannotCreateMainAccountError, ParentAccountNotFoundError, AccountCodeConflictError, InvalidCustomCodeError } from './errors';
|
|
6
|
+
export interface ValidatedAccountInput extends CustomAccountInput {
|
|
7
|
+
level: number;
|
|
8
|
+
classCode: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class CustomAccountValidator {
|
|
11
|
+
private registry;
|
|
12
|
+
private customAccounts;
|
|
13
|
+
constructor(registry: AccountRegistry, customAccounts: Map<string, CustomAccountData>);
|
|
14
|
+
setCustomAccounts(customAccounts: Map<string, CustomAccountData>): void;
|
|
15
|
+
isMainAccount(code: string): boolean;
|
|
16
|
+
accountExists(code: string): boolean;
|
|
17
|
+
getAccount(code: string): Account | CustomAccountData | null;
|
|
18
|
+
validateCodeFormat(code: string, parentCode: string): Result<string, InvalidCustomCodeError>;
|
|
19
|
+
validateCreate(input: CustomAccountInput): Result<ValidatedAccountInput, CannotCreateMainAccountError | ParentAccountNotFoundError | AccountCodeConflictError | InvalidCustomCodeError>;
|
|
20
|
+
validateLabelUpdate(code: string): Result<Account | CustomAccountData, CannotModifyMainAccountError | InvalidCustomCodeError>;
|
|
21
|
+
validateDelete(code: string, customAccounts: Map<string, CustomAccountData>): Result<CustomAccountData, InvalidCustomCodeError>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=CustomAccountValidator.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { OhadaKitError } from '../validation/errors';
|
|
2
|
+
export declare abstract class CustomAccountError extends OhadaKitError {
|
|
3
|
+
abstract readonly code: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class CannotModifyMainAccountError extends CustomAccountError {
|
|
6
|
+
readonly code = "CANNOT_MODIFY_MAIN_ACCOUNT";
|
|
7
|
+
readonly accountCode: string;
|
|
8
|
+
constructor(accountCode: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class CannotCreateMainAccountError extends CustomAccountError {
|
|
11
|
+
readonly code = "CANNOT_CREATE_MAIN_ACCOUNT";
|
|
12
|
+
readonly accountCode: string;
|
|
13
|
+
constructor(accountCode: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class ParentAccountNotFoundError extends CustomAccountError {
|
|
16
|
+
readonly code = "PARENT_ACCOUNT_NOT_FOUND";
|
|
17
|
+
readonly parentCode: string;
|
|
18
|
+
constructor(parentCode: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class AccountCodeConflictError extends CustomAccountError {
|
|
21
|
+
readonly code = "ACCOUNT_CODE_CONFLICT";
|
|
22
|
+
readonly accountCode: string;
|
|
23
|
+
constructor(accountCode: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class InvalidCustomCodeError extends CustomAccountError {
|
|
26
|
+
readonly code = "INVALID_CUSTOM_CODE";
|
|
27
|
+
readonly accountCode: string;
|
|
28
|
+
readonly reason: string;
|
|
29
|
+
constructor(accountCode: string, reason: string);
|
|
30
|
+
}
|
|
31
|
+
export declare class CustomStorageError extends CustomAccountError {
|
|
32
|
+
readonly code = "CUSTOM_STORAGE_ERROR";
|
|
33
|
+
readonly operation: string;
|
|
34
|
+
readonly originalError?: Error;
|
|
35
|
+
constructor(operation: string, message: string, originalError?: Error);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CustomAccountManager } from './CustomAccountManager';
|
|
2
|
+
export { CustomAccountValidator } from './CustomAccountValidator';
|
|
3
|
+
export type { ValidatedAccountInput } from './CustomAccountValidator';
|
|
4
|
+
export { CustomAccountIndex } from './CustomAccountIndex';
|
|
5
|
+
export type { CustomAccountInput, CustomAccountData, LabelOverride, CustomAccountStorage, CustomAccountManagerOptions, CreateAccountResult, UpdateLabelResult, DeleteAccountResult, CustomAccountStats, } from './types';
|
|
6
|
+
export { STORAGE_KEYS, DEFAULT_STORAGE_PREFIX, STORAGE_VERSION, } from './types';
|
|
7
|
+
export { CustomAccountError, CannotModifyMainAccountError, CannotCreateMainAccountError, ParentAccountNotFoundError, AccountCodeConflictError, InvalidCustomCodeError, CustomStorageError, } from './errors';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { StorageAdapter, Result } from '../core/types';
|
|
2
|
+
import type { Account } from '../core/Account';
|
|
3
|
+
export interface CustomAccountInput {
|
|
4
|
+
code: string;
|
|
5
|
+
name: string;
|
|
6
|
+
parentCode: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CustomAccountData {
|
|
9
|
+
code: string;
|
|
10
|
+
name: string;
|
|
11
|
+
level: number;
|
|
12
|
+
classCode: string;
|
|
13
|
+
parentCode: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
isCustom: true;
|
|
17
|
+
}
|
|
18
|
+
export interface LabelOverride {
|
|
19
|
+
code: string;
|
|
20
|
+
originalName: string;
|
|
21
|
+
customName: string;
|
|
22
|
+
modifiedAt: string;
|
|
23
|
+
}
|
|
24
|
+
export interface CustomAccountStorage {
|
|
25
|
+
version: 1;
|
|
26
|
+
accounts: CustomAccountData[];
|
|
27
|
+
labelOverrides: LabelOverride[];
|
|
28
|
+
metadata: {
|
|
29
|
+
lastModified: string;
|
|
30
|
+
accountCount: number;
|
|
31
|
+
overrideCount: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface CustomAccountManagerOptions {
|
|
35
|
+
storage: StorageAdapter;
|
|
36
|
+
storagePrefix?: string;
|
|
37
|
+
}
|
|
38
|
+
export type CreateAccountResult = Result<Account>;
|
|
39
|
+
export type UpdateLabelResult = Result<Account>;
|
|
40
|
+
export type DeleteAccountResult = Result<void>;
|
|
41
|
+
export interface CustomAccountStats {
|
|
42
|
+
customAccountCount: number;
|
|
43
|
+
labelOverrideCount: number;
|
|
44
|
+
byClass: Record<string, number>;
|
|
45
|
+
lastModified: string | null;
|
|
46
|
+
}
|
|
47
|
+
export declare const STORAGE_KEYS: {
|
|
48
|
+
readonly CUSTOM_ACCOUNTS: "custom:accounts";
|
|
49
|
+
};
|
|
50
|
+
export declare const DEFAULT_STORAGE_PREFIX = "ohadakit:";
|
|
51
|
+
export declare const STORAGE_VERSION = 1;
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OhadaFlatAccount } from './types';
|
|
2
|
+
export declare const flatAccounts: OhadaFlatAccount[];
|
|
3
|
+
export declare function getAccountsByClass(classCode: string): OhadaFlatAccount[];
|
|
4
|
+
export declare function getAccountsByLevel(level: number): OhadaFlatAccount[];
|
|
5
|
+
export declare function getAccountByCode(code: string): OhadaFlatAccount | undefined;
|
|
6
|
+
export declare function getChildAccounts(parentCode: string): OhadaFlatAccount[];
|
|
7
|
+
export declare function searchFlatAccounts(query: string): OhadaFlatAccount[];
|
|
8
|
+
export declare const flatAccountsStats: {
|
|
9
|
+
total: number;
|
|
10
|
+
byClass: {
|
|
11
|
+
class1: number;
|
|
12
|
+
class2: number;
|
|
13
|
+
class3: number;
|
|
14
|
+
class4: number;
|
|
15
|
+
class5: number;
|
|
16
|
+
class6: number;
|
|
17
|
+
class7: number;
|
|
18
|
+
class8: number;
|
|
19
|
+
class9: number;
|
|
20
|
+
};
|
|
21
|
+
byLevel: {
|
|
22
|
+
level2: number;
|
|
23
|
+
level3: number;
|
|
24
|
+
level4: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=accounts-flat.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OhadaChartIndex, OhadaClass, OhadaAccount } from './types';
|
|
2
|
+
import { ohadaClasses } from './classes';
|
|
3
|
+
import { class1 } from './class-1-ressources';
|
|
4
|
+
import { class2 } from './class-2-immobilisations';
|
|
5
|
+
import { class3 } from './class-3-stocks';
|
|
6
|
+
import { class4 } from './class-4-tiers';
|
|
7
|
+
import { class5 } from './class-5-tresorerie';
|
|
8
|
+
import { class6 } from './class-6-charges';
|
|
9
|
+
import { class7 } from './class-7-produits';
|
|
10
|
+
import { class8 } from './class-8-hao';
|
|
11
|
+
import { class9 } from './class-9-engagements';
|
|
12
|
+
export declare const ohadaChartIndex: OhadaChartIndex;
|
|
13
|
+
export declare const allClasses: OhadaClass[];
|
|
14
|
+
export declare function getClass(classCode: string): OhadaClass | undefined;
|
|
15
|
+
export declare function findAccount(accountCode: string): OhadaAccount | undefined;
|
|
16
|
+
export declare function getAccountsByLevel(level: number): OhadaAccount[];
|
|
17
|
+
export declare function searchAccounts(query: string): OhadaAccount[];
|
|
18
|
+
export declare function getAccountWithPath(accountCode: string): {
|
|
19
|
+
account: OhadaAccount;
|
|
20
|
+
path: string[];
|
|
21
|
+
} | undefined;
|
|
22
|
+
export declare function getTotalAccountCount(): number;
|
|
23
|
+
export * from './types';
|
|
24
|
+
export { class1, class2, class3, class4, class5, class6, class7, class8, class9 };
|
|
25
|
+
export { ohadaClasses };
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|