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,39 @@
|
|
|
1
|
+
export interface OhadaAccount {
|
|
2
|
+
code: string;
|
|
3
|
+
name: string;
|
|
4
|
+
level: number;
|
|
5
|
+
parentCode?: string;
|
|
6
|
+
subAccounts?: OhadaAccount[];
|
|
7
|
+
}
|
|
8
|
+
export interface OhadaFlatAccount {
|
|
9
|
+
code: string;
|
|
10
|
+
name: string;
|
|
11
|
+
level: number;
|
|
12
|
+
classCode: string;
|
|
13
|
+
parentCode?: string;
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
export interface OhadaClass {
|
|
17
|
+
code: string;
|
|
18
|
+
name: string;
|
|
19
|
+
nameEn?: string;
|
|
20
|
+
namePt?: string;
|
|
21
|
+
nameEs?: string;
|
|
22
|
+
accounts: OhadaAccount[];
|
|
23
|
+
}
|
|
24
|
+
export interface OhadaClassReference {
|
|
25
|
+
code: string;
|
|
26
|
+
name: string;
|
|
27
|
+
nameEn?: string;
|
|
28
|
+
namePt?: string;
|
|
29
|
+
nameEs?: string;
|
|
30
|
+
file: string;
|
|
31
|
+
}
|
|
32
|
+
export interface OhadaChartIndex {
|
|
33
|
+
version: string;
|
|
34
|
+
name: string;
|
|
35
|
+
source: string;
|
|
36
|
+
date: string;
|
|
37
|
+
classes: OhadaClassReference[];
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RawAccountData, OhadaClass } from '../core/types';
|
|
2
|
+
export declare const OHADA_CLASSES: Record<string, OhadaClass>;
|
|
3
|
+
export declare function loadOhadaAccounts(): RawAccountData[];
|
|
4
|
+
export declare function getClassMetadata(classCode: string): OhadaClass | null;
|
|
5
|
+
export declare function getAllClassCodes(): string[];
|
|
6
|
+
//# sourceMappingURL=ohada-accounts.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Account } from '../core/Account';
|
|
2
|
+
import type { JsonExportOptions, CsvExportOptions } from '../core/types';
|
|
3
|
+
export declare class JsonExporter {
|
|
4
|
+
static export(accounts: Account[], options?: JsonExportOptions): string;
|
|
5
|
+
private static buildHierarchical;
|
|
6
|
+
}
|
|
7
|
+
export declare class CsvExporter {
|
|
8
|
+
static export(accounts: Account[], options?: CsvExportOptions): string;
|
|
9
|
+
private static escapeCSV;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Exporter.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OhadaLocale, LocalizedString } from './types';
|
|
2
|
+
export declare class TranslationService {
|
|
3
|
+
private static readonly VALID_LOCALES;
|
|
4
|
+
private locale;
|
|
5
|
+
constructor(locale?: OhadaLocale);
|
|
6
|
+
static isValidLocale(locale: string): locale is OhadaLocale;
|
|
7
|
+
getAccountName(code: string, fallbackName: string): string;
|
|
8
|
+
getAccountTranslations(code: string): LocalizedString | null;
|
|
9
|
+
hasTranslation(code: string): boolean;
|
|
10
|
+
hasLocaleTranslation(code: string, locale: OhadaLocale): boolean;
|
|
11
|
+
getLocale(): OhadaLocale;
|
|
12
|
+
setLocale(locale: OhadaLocale): void;
|
|
13
|
+
static getAvailableLocales(): OhadaLocale[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=TranslationService.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { OhadaLocale } from '../core/types';
|
|
2
|
+
export interface LocalizedString {
|
|
3
|
+
fr: string;
|
|
4
|
+
en?: string;
|
|
5
|
+
pt?: string;
|
|
6
|
+
es?: string;
|
|
7
|
+
}
|
|
8
|
+
export type AccountTranslations = Record<string, LocalizedString>;
|
|
9
|
+
export interface ClassTranslations {
|
|
10
|
+
name: LocalizedString;
|
|
11
|
+
description?: LocalizedString;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { LedgerEngine, createLedgerEngine, getDefaultLedgerEngine } from './LedgerEngine';
|
|
2
|
+
export { AccountBook, createAccountBook } from './AccountBook';
|
|
3
|
+
export type { CreateAccountBookOptions } from './AccountBook';
|
|
4
|
+
export { Account, isAccount } from './core/Account';
|
|
5
|
+
export { AccountRegistry, getDefaultRegistry, resetDefaultRegistry } from './core/AccountRegistry';
|
|
6
|
+
export { AccountIndex } from './core/AccountIndex';
|
|
7
|
+
export { QueryBuilder } from './query/QueryEngine';
|
|
8
|
+
export { MemoryStorage } from './storage/MemoryStorage';
|
|
9
|
+
export { LocalStorageAdapter } from './storage/LocalStorage';
|
|
10
|
+
export { JsonExporter, CsvExporter } from './export/Exporter';
|
|
11
|
+
export { validateAccountCode, validateAccountCodeFormat, validateClassCode, validateAccountLevel, isValidAccountCodeFormat, isValidClassCode, sanitizeAccountCode, getAccountLevelFromCode, extractClassCode, extractParentCode, } from './validation/validators';
|
|
12
|
+
export { OhadaKitError, AccountNotFoundError, InvalidAccountCodeFormatError, InvalidAccountLevelError, InvalidClassCodeError, StorageError, ExportError, } from './validation/errors';
|
|
13
|
+
export type { AccountCode, ClassCode, Result, RawAccountData, AccountMetadata, AccountJSON, OhadaClass, OhadaLocale, QueryFilter, SearchOptions, SortOptions, RegistryStats, ExportFormat, JsonStructure, JsonExportOptions, CsvExportOptions, ExportOptions, StorageAdapter, LedgerEngineOptions, AccountBookOptions, AccountBookSnapshot, AccountBookStats, } from './core/types';
|
|
14
|
+
export { TranslationService } from './i18n/TranslationService';
|
|
15
|
+
export { accountTranslations } from './i18n/account-names';
|
|
16
|
+
export type { LocalizedString, AccountTranslations, ClassTranslations } from './i18n/types';
|
|
17
|
+
export { Ok, Err, isOk, isErr, isClassCode } from './core/types';
|
|
18
|
+
export { loadOhadaAccounts, getClassMetadata, getAllClassCodes, OHADA_CLASSES } from './data/ohada-accounts';
|
|
19
|
+
export { CustomAccountManager } from './custom/CustomAccountManager';
|
|
20
|
+
export { CustomAccountValidator } from './custom/CustomAccountValidator';
|
|
21
|
+
export { CustomAccountIndex } from './custom/CustomAccountIndex';
|
|
22
|
+
export type { CustomAccountInput, CustomAccountData, LabelOverride, CustomAccountStorage, CustomAccountManagerOptions, CreateAccountResult, UpdateLabelResult, DeleteAccountResult, CustomAccountStats, } from './custom/types';
|
|
23
|
+
export { STORAGE_KEYS as CUSTOM_STORAGE_KEYS, DEFAULT_STORAGE_PREFIX, STORAGE_VERSION, } from './custom/types';
|
|
24
|
+
export { CustomAccountError, CannotModifyMainAccountError, CannotCreateMainAccountError, ParentAccountNotFoundError, AccountCodeConflictError, InvalidCustomCodeError, CustomStorageError, } from './custom/errors';
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Account } from '../core/Account';
|
|
2
|
+
import type { AccountRegistry } from '../core/AccountRegistry';
|
|
3
|
+
import type { SearchOptions } from '../core/types';
|
|
4
|
+
export declare class QueryBuilder {
|
|
5
|
+
private registry;
|
|
6
|
+
private filters;
|
|
7
|
+
private searchText?;
|
|
8
|
+
private searchOpts?;
|
|
9
|
+
private sortOpts?;
|
|
10
|
+
private limitValue?;
|
|
11
|
+
private offsetValue?;
|
|
12
|
+
constructor(registry: AccountRegistry);
|
|
13
|
+
inClass(classCode: string | string[]): this;
|
|
14
|
+
atLevel(level: number | number[]): this;
|
|
15
|
+
withParent(parentCode: string): this;
|
|
16
|
+
nameContains(text: string): this;
|
|
17
|
+
codeMatches(pattern: RegExp): this;
|
|
18
|
+
where(predicate: (account: Account) => boolean): this;
|
|
19
|
+
search(text: string, options?: SearchOptions): this;
|
|
20
|
+
sortBy(by: 'code' | 'name' | 'level', direction?: 'asc' | 'desc'): this;
|
|
21
|
+
limit(count: number): this;
|
|
22
|
+
offset(count: number): this;
|
|
23
|
+
execute(): Account[];
|
|
24
|
+
count(): number;
|
|
25
|
+
first(): Account | null;
|
|
26
|
+
exists(): boolean;
|
|
27
|
+
private applyFilters;
|
|
28
|
+
private applySorting;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=QueryEngine.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StorageAdapter } from '../core/types';
|
|
2
|
+
export declare class LocalStorageAdapter implements StorageAdapter {
|
|
3
|
+
private prefix;
|
|
4
|
+
private storage;
|
|
5
|
+
constructor(prefix?: string);
|
|
6
|
+
private getPrefixedKey;
|
|
7
|
+
private removePrefixFromKey;
|
|
8
|
+
get(key: string): Promise<string | null>;
|
|
9
|
+
set(key: string, value: string): Promise<void>;
|
|
10
|
+
delete(key: string): Promise<void>;
|
|
11
|
+
getAll(): Promise<Map<string, string>>;
|
|
12
|
+
clear(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=LocalStorage.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StorageAdapter } from '../core/types';
|
|
2
|
+
export declare class MemoryStorage implements StorageAdapter {
|
|
3
|
+
private storage;
|
|
4
|
+
constructor();
|
|
5
|
+
get(key: string): Promise<string | null>;
|
|
6
|
+
set(key: string, value: string): Promise<void>;
|
|
7
|
+
delete(key: string): Promise<void>;
|
|
8
|
+
getAll(): Promise<Map<string, string>>;
|
|
9
|
+
clear(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=MemoryStorage.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare abstract class OhadaKitError extends Error {
|
|
2
|
+
abstract readonly code: string;
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
toJSON(): {
|
|
5
|
+
name: string;
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare class AccountNotFoundError extends OhadaKitError {
|
|
11
|
+
readonly code = "ACCOUNT_NOT_FOUND";
|
|
12
|
+
readonly accountCode: string;
|
|
13
|
+
constructor(accountCode: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class InvalidAccountCodeFormatError extends OhadaKitError {
|
|
16
|
+
readonly code = "INVALID_ACCOUNT_CODE_FORMAT";
|
|
17
|
+
readonly accountCode: string;
|
|
18
|
+
readonly reason: string;
|
|
19
|
+
constructor(accountCode: string, reason: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class InvalidAccountLevelError extends OhadaKitError {
|
|
22
|
+
readonly code = "INVALID_ACCOUNT_LEVEL";
|
|
23
|
+
readonly level: number;
|
|
24
|
+
constructor(level: number);
|
|
25
|
+
}
|
|
26
|
+
export declare class InvalidClassCodeError extends OhadaKitError {
|
|
27
|
+
readonly code = "INVALID_CLASS_CODE";
|
|
28
|
+
readonly classCode: string;
|
|
29
|
+
constructor(classCode: string);
|
|
30
|
+
}
|
|
31
|
+
export declare class StorageError extends OhadaKitError {
|
|
32
|
+
readonly code = "STORAGE_ERROR";
|
|
33
|
+
readonly operation: string;
|
|
34
|
+
readonly originalError?: Error;
|
|
35
|
+
constructor(operation: string, message: string, originalError?: Error);
|
|
36
|
+
}
|
|
37
|
+
export declare class ExportError extends OhadaKitError {
|
|
38
|
+
readonly code = "EXPORT_ERROR";
|
|
39
|
+
readonly format: string;
|
|
40
|
+
readonly originalError?: Error;
|
|
41
|
+
constructor(format: string, message: string, originalError?: Error);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Result } from '../core/types';
|
|
2
|
+
import type { Account } from '../core/Account';
|
|
3
|
+
import type { AccountRegistry } from '../core/AccountRegistry';
|
|
4
|
+
export declare function validateAccountCodeFormat(code: string): Result<string>;
|
|
5
|
+
export declare function validateClassCode(code: string): Result<string>;
|
|
6
|
+
export declare function validateAccountLevel(level: number): Result<number>;
|
|
7
|
+
export declare function validateAccountCode(code: string, registry: AccountRegistry): Result<Account>;
|
|
8
|
+
export declare function isValidAccountCodeFormat(code: string): boolean;
|
|
9
|
+
export declare function isValidClassCode(code: string): boolean;
|
|
10
|
+
export declare function sanitizeAccountCode(code: string): string;
|
|
11
|
+
export declare function getAccountLevelFromCode(code: string): number;
|
|
12
|
+
export declare function extractClassCode(code: string): string;
|
|
13
|
+
export declare function extractParentCode(code: string): string | null;
|
|
14
|
+
//# sourceMappingURL=validators.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ohadakit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript SDK for the OHADA/SYSCOHADA chart of accounts — O(1) lookups, querying, custom accounts, i18n, and export",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cjs/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
13
|
+
"browser": "./dist/browser/ohadakit.umd.js",
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./browser": {
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"import": "./dist/browser/ohadakit.iife.js",
|
|
20
|
+
"default": "./dist/browser/ohadakit.umd.js"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/esm/**/*.js",
|
|
26
|
+
"dist/cjs/**/*.js",
|
|
27
|
+
"dist/types/**/*.d.ts",
|
|
28
|
+
"dist/browser/**/*.js",
|
|
29
|
+
"!dist/**/*.map",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "npm run clean && npm run build:types && npm run build:lib && npm run build:browser && npm run build:report",
|
|
35
|
+
"build:types": "tsc --project tsconfig.build.json",
|
|
36
|
+
"build:lib": "vite build --mode production",
|
|
37
|
+
"build:browser": "vite build --config vite.config.browser.ts --mode production",
|
|
38
|
+
"build:report": "node scripts/build-report.js",
|
|
39
|
+
"clean": "rm -rf dist",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:watch": "vitest --watch",
|
|
42
|
+
"test:coverage": "vitest run --coverage",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"prepublishOnly": "npm run typecheck && npm run test && npm run build"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"ohada",
|
|
48
|
+
"syscohada",
|
|
49
|
+
"accounting",
|
|
50
|
+
"chart-of-accounts",
|
|
51
|
+
"ledger",
|
|
52
|
+
"typescript",
|
|
53
|
+
"sdk"
|
|
54
|
+
],
|
|
55
|
+
"author": "Justin Dah-kenangnon <dah.kenangnon@gmail.com>",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/Dahkenangnon/OhadaKit.git"
|
|
60
|
+
},
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/Dahkenangnon/OhadaKit/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/Dahkenangnon/OhadaKit#readme",
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/node": "^20.0.0",
|
|
67
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
68
|
+
"typescript": "^5.3.0",
|
|
69
|
+
"vite": "^7.2.6",
|
|
70
|
+
"vitest": "^1.0.0"
|
|
71
|
+
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=16.0.0"
|
|
74
|
+
}
|
|
75
|
+
}
|