@luca-financial/luca-schema 1.3.0 → 2.1.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +4 -35
  2. package/README.md +33 -40
  3. package/dist/esm/enums.js +6 -0
  4. package/dist/esm/index.d.ts +1194 -0
  5. package/dist/esm/index.js +18 -0
  6. package/dist/esm/lucaValidator.js +59 -0
  7. package/dist/esm/schemas/account.json +69 -0
  8. package/dist/esm/schemas/category.json +11 -37
  9. package/dist/esm/schemas/common.json +16 -0
  10. package/dist/esm/schemas/enums.json +59 -0
  11. package/dist/esm/schemas/index.js +36 -0
  12. package/dist/esm/schemas/lucaSchema.json +23 -5
  13. package/dist/esm/schemas/recurringTransaction.json +15 -20
  14. package/dist/esm/schemas/recurringTransactionEvent.json +28 -22
  15. package/dist/esm/schemas/statement.json +70 -0
  16. package/dist/esm/schemas/transaction.json +64 -43
  17. package/dist/esm/schemas/transactionSplit.json +43 -0
  18. package/dist/index.d.ts +1194 -4
  19. package/package.json +35 -34
  20. package/dist/cjs/package.json +0 -3
  21. package/dist/cjs/schemas/category.json +0 -63
  22. package/dist/cjs/schemas/common.json +0 -30
  23. package/dist/cjs/schemas/entity.json +0 -44
  24. package/dist/cjs/schemas/index.ts +0 -30
  25. package/dist/cjs/schemas/lucaSchema.json +0 -61
  26. package/dist/cjs/schemas/recurringTransaction.json +0 -86
  27. package/dist/cjs/schemas/recurringTransactionEvent.json +0 -58
  28. package/dist/cjs/schemas/transaction.json +0 -76
  29. package/dist/enums.d.ts +0 -12
  30. package/dist/enums.js +0 -68
  31. package/dist/esm/schemas/entity.json +0 -44
  32. package/dist/esm/schemas/index.ts +0 -30
  33. package/dist/index.js +0 -4
  34. package/dist/lucaValidator.d.ts +0 -54
  35. package/dist/lucaValidator.js +0 -34
  36. package/dist/schemas/category.json +0 -63
  37. package/dist/schemas/common.json +0 -30
  38. package/dist/schemas/entity.json +0 -44
  39. package/dist/schemas/index.d.ts +0 -12
  40. package/dist/schemas/index.js +0 -17
  41. package/dist/schemas/lucaSchema.json +0 -61
  42. package/dist/schemas/recurringTransaction.json +0 -86
  43. package/dist/schemas/recurringTransactionEvent.json +0 -58
  44. package/dist/schemas/transaction.json +0 -76
  45. package/dist/tests/test-utils.d.ts +0 -37
  46. package/dist/tests/test-utils.js +0 -115
  47. package/dist/types/enums.d.ts +0 -8
  48. package/dist/types/enums.js +0 -1
package/CHANGELOG.md CHANGED
@@ -5,41 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [1.3.0] - 2025-10-11
8
+ ## [Unreleased]
9
9
 
10
- ### Added
11
-
12
- - Full TypeScript support with comprehensive type definitions
13
- - Modern CI/CD pipeline with Node.js 20.x and 22.x support
14
- - Comprehensive test suite with 95% code coverage
15
- - Pre-commit hooks with lint-staged for code quality
16
- - Test utilities for creating mock data objects
17
- - Enhanced error handling and validation interfaces
18
- - Dual ESM/CJS build support
19
- - Professional package metadata and documentation
20
-
21
- ### Changed
22
-
23
- - **BREAKING**: Migrated from JavaScript to TypeScript
24
- - Updated minimum Node.js requirement to >=20.0.0
25
- - Replaced console.error statements with proper error throwing
26
- - Enhanced README with TypeScript examples and better documentation
27
- - Improved build system with TypeScript compilation
28
- - Updated dependencies to latest secure versions
29
-
30
- ### Removed
10
+ ## [2.0.0] - 2026-01-03
31
11
 
32
- - **BREAKING**: Removed Node.js 18.x support
33
- - Removed deprecated Husky installation scripts
34
- - Removed console pollution from library code
35
-
36
- ### Fixed
37
-
38
- - CI/CD pipeline compatibility with modern Node.js versions
39
- - Husky pre-commit hooks updated to v9 format
40
- - ESLint configuration optimized for TypeScript projects
41
-
42
- ## [1.2.3] - Previous releases
12
+ ### Added
43
13
 
44
- - Legacy JavaScript implementation
45
- - Basic schema validation functionality
14
+ - Initial release of version 2.0.0 schema.
package/README.md CHANGED
@@ -11,34 +11,25 @@ npm install @luca-financial/luca-schema
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import { lucaValidator, enums, schemas } from '@luca-financial/luca-schema';
14
+ import { validate } from '@luca-financial/luca-schema';
15
15
 
16
- // Validate a transaction
17
- const validateTransaction = lucaValidator.getSchema('transaction');
18
16
  const transactionData = {
19
17
  id: '123e4567-e89b-12d3-a456-426614174000',
20
- payorId: '123e4567-e89b-12d3-a456-426614174001',
21
- payeeId: '123e4567-e89b-12d3-a456-426614174002',
22
- categoryId: '123e4567-e89b-12d3-a456-426614174003',
23
- amount: 100.5,
18
+ accountId: '123e4567-e89b-12d3-a456-426614174001',
19
+ categoryId: null,
20
+ statementId: null,
21
+ amount: -2599,
24
22
  date: '2024-01-01',
25
23
  description: 'Test transaction',
26
- transactionState: enums.TransactionStateEnum.COMPLETED,
24
+ transactionState: 'COMPLETED',
27
25
  createdAt: '2024-01-01T00:00:00Z',
28
26
  updatedAt: null
29
27
  };
30
28
 
31
- const isValid = validateTransaction(transactionData);
32
-
33
- if (!isValid) {
34
- console.error('Validation errors:', validateTransaction.errors);
29
+ const result = validate('transaction', transactionData);
30
+ if (!result.valid) {
31
+ console.error('Validation errors:', result.errors);
35
32
  }
36
-
37
- // Alternative: Use schemas directly with the validate method
38
- const isValidDirect = lucaValidator.validate(
39
- schemas.transaction,
40
- transactionData
41
- );
42
33
  ```
43
34
 
44
35
  ## Available Schemas
@@ -50,9 +41,9 @@ Validates financial transactions with properties like amount, date, and state.
50
41
  ```typescript
51
42
  const transaction = {
52
43
  id: string;
53
- payorId: string;
54
- payeeId: string;
44
+ accountId: string;
55
45
  categoryId: string | null;
46
+ statementId: string | null;
56
47
  amount: number;
57
48
  date: string;
58
49
  description: string;
@@ -69,8 +60,7 @@ Validates recurring transaction templates with frequency and interval settings.
69
60
  ```typescript
70
61
  const recurringTransaction = {
71
62
  id: string;
72
- payorId: string;
73
- payeeId: string;
63
+ accountId: string;
74
64
  categoryId: string | null;
75
65
  amount: number;
76
66
  description: string;
@@ -85,22 +75,6 @@ const recurringTransaction = {
85
75
  };
86
76
  ```
87
77
 
88
- ### Entity
89
-
90
- Validates financial entities like accounts, retailers, or individuals.
91
-
92
- ```typescript
93
- const entity = {
94
- id: string;
95
- name: string;
96
- description: string | null;
97
- entityType: 'ACCOUNT' | 'RETAILER' | 'SERVICE' | 'INDIVIDUAL' | 'UTILITY' | 'GOVERNMENT';
98
- entityStatus: 'ACTIVE' | 'INACTIVE' | 'SUSPENDED' | 'DELETED' | 'CLOSED';
99
- createdAt: string;
100
- updatedAt: string | null;
101
- };
102
- ```
103
-
104
78
  ### Category
105
79
 
106
80
  Validates transaction categories with optional parent relationships.
@@ -108,11 +82,10 @@ Validates transaction categories with optional parent relationships.
108
82
  ```typescript
109
83
  const category = {
110
84
  id: string;
85
+ slug: string;
111
86
  name: string;
112
87
  description: string | null;
113
88
  parentId: string | null;
114
- defaultCategoryId: string | null;
115
- categoryType: 'DEFAULT' | 'MODIFIED' | 'CUSTOM';
116
89
  createdAt: string;
117
90
  updatedAt: string | null;
118
91
  };
@@ -134,6 +107,26 @@ const recurringTransactionEvent = {
134
107
  };
135
108
  ```
136
109
 
110
+ ### Statement
111
+
112
+ Validates credit card statements with balances in integer minor units.
113
+
114
+ ```typescript
115
+ const statement = {
116
+ id: string;
117
+ accountId: string;
118
+ startDate: string;
119
+ endDate: string;
120
+ startingBalance: number;
121
+ endingBalance: number;
122
+ totalCharges: number;
123
+ totalPayments: number;
124
+ status: 'draft' | 'current' | 'past' | 'locked';
125
+ createdAt: string;
126
+ updatedAt: string | null;
127
+ };
128
+ ```
129
+
137
130
  ## Development
138
131
 
139
132
  ```bash
@@ -0,0 +1,6 @@
1
+ import enumsJson from './schemas/enums.json' with { type: 'json' };
2
+
3
+ export const LucaSchemas = enumsJson.LucaSchemas;
4
+ export const enums = enumsJson.$defs;
5
+
6
+ export default enums;