@luca-financial/luca-schema 2.3.1 → 2.3.4
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/CHANGELOG.md +47 -1
- package/README.md +128 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,11 +5,57 @@ 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
|
-
## [
|
|
8
|
+
## [2.3.4] - 2026-02-06
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Fixed release workflow for tag, release, and publish cycle.
|
|
13
|
+
- Publish prereleases with appropriate npm dist-tag and use trusted publisher OIDC.
|
|
14
|
+
|
|
15
|
+
## [2.3.3] - 2026-02-06
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Update release workflow to use npm trusted publisher (OIDC) instead of an access token.
|
|
20
|
+
|
|
21
|
+
## [2.3.2] - 2026-02-06
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Update README schema documentation and validator utilities.
|
|
26
|
+
- Update changelog entries for recent releases.
|
|
27
|
+
- Add pull request template with changelog checklist item.
|
|
28
|
+
|
|
29
|
+
## [v2.3.1] - 2026-02-01
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- Remove `applyDefaults` helper and update schemas.
|
|
34
|
+
|
|
35
|
+
## [v2.3.0] - 2026-02-01
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- Remove `deletedAt` field and refactor validation logic.
|
|
40
|
+
|
|
41
|
+
## [v2.2.0] - 2026-02-01
|
|
9
42
|
|
|
10
43
|
### Changed
|
|
11
44
|
|
|
12
45
|
- Replace statement `status` with boolean `isLocked` and remove `StatementStatus` enum.
|
|
46
|
+
- Breaking change from 2.1.5 to 2.2.0.
|
|
47
|
+
|
|
48
|
+
## [2.1.5] - 2026-01-19
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- Add comprehensive example JSON dataset for development and testing.
|
|
53
|
+
|
|
54
|
+
## [2.1.4] - 2026-01-19
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
|
|
58
|
+
- Rename copilot-rules.md to copilot-instructions.md and restructure content.
|
|
13
59
|
|
|
14
60
|
## [2.1.3] - 2026-01-18
|
|
15
61
|
|
package/README.md
CHANGED
|
@@ -34,6 +34,43 @@ if (!result.valid) {
|
|
|
34
34
|
|
|
35
35
|
## Available Schemas
|
|
36
36
|
|
|
37
|
+
### Common Fields
|
|
38
|
+
|
|
39
|
+
All entity schemas include common fields:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const common = {
|
|
43
|
+
id: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
updatedAt: string | null;
|
|
46
|
+
deletedAt?: string | null;
|
|
47
|
+
version?: number;
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Account
|
|
52
|
+
|
|
53
|
+
Validates financial accounts.
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const account = {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
type: 'CHECKING' | 'SAVINGS' | 'CREDIT_CARD' | 'EXTERNAL';
|
|
60
|
+
institution: string | null;
|
|
61
|
+
aggregationServiceId: string | null;
|
|
62
|
+
statementClosingDay: number | null;
|
|
63
|
+
paymentDueDate: string | null;
|
|
64
|
+
creditLimit: number | null;
|
|
65
|
+
apr: number | null;
|
|
66
|
+
closedAt: string | null;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
updatedAt: string | null;
|
|
69
|
+
deletedAt?: string | null;
|
|
70
|
+
version?: number;
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
37
74
|
### Transaction
|
|
38
75
|
|
|
39
76
|
Validates financial transactions with properties like amount, date, and state.
|
|
@@ -44,12 +81,28 @@ const transaction = {
|
|
|
44
81
|
accountId: string;
|
|
45
82
|
categoryId: string | null;
|
|
46
83
|
statementId: string | null;
|
|
84
|
+
authorizedAt: string | null;
|
|
85
|
+
postedAt: string | null;
|
|
86
|
+
currency: string | null;
|
|
47
87
|
amount: number;
|
|
48
88
|
date: string;
|
|
49
89
|
description: string;
|
|
50
|
-
|
|
90
|
+
aggregationServiceId: string | null;
|
|
91
|
+
transactionState:
|
|
92
|
+
| 'PLANNED'
|
|
93
|
+
| 'ON_DECK'
|
|
94
|
+
| 'SCHEDULED'
|
|
95
|
+
| 'PENDING'
|
|
96
|
+
| 'COMPLETED'
|
|
97
|
+
| 'CANCELLED'
|
|
98
|
+
| 'FAILED'
|
|
99
|
+
| 'DISPUTED'
|
|
100
|
+
| 'REFUNDED'
|
|
101
|
+
| 'DELETED';
|
|
51
102
|
createdAt: string;
|
|
52
103
|
updatedAt: string | null;
|
|
104
|
+
deletedAt?: string | null;
|
|
105
|
+
version?: number;
|
|
53
106
|
};
|
|
54
107
|
```
|
|
55
108
|
|
|
@@ -72,6 +125,8 @@ const recurringTransaction = {
|
|
|
72
125
|
recurringTransactionState: 'ACTIVE' | 'PAUSED' | 'COMPLETED' | 'CANCELLED';
|
|
73
126
|
createdAt: string;
|
|
74
127
|
updatedAt: string | null;
|
|
128
|
+
deletedAt?: string | null;
|
|
129
|
+
version?: number;
|
|
75
130
|
};
|
|
76
131
|
```
|
|
77
132
|
|
|
@@ -88,6 +143,8 @@ const category = {
|
|
|
88
143
|
parentId: string | null;
|
|
89
144
|
createdAt: string;
|
|
90
145
|
updatedAt: string | null;
|
|
146
|
+
deletedAt?: string | null;
|
|
147
|
+
version?: number;
|
|
91
148
|
};
|
|
92
149
|
```
|
|
93
150
|
|
|
@@ -98,12 +155,14 @@ Validates events that track changes to recurring transactions.
|
|
|
98
155
|
```typescript
|
|
99
156
|
const recurringTransactionEvent = {
|
|
100
157
|
id: string;
|
|
101
|
-
transactionId: string;
|
|
158
|
+
transactionId: string | null;
|
|
102
159
|
recurringTransactionId: string;
|
|
103
160
|
expectedDate: string;
|
|
104
161
|
eventState: 'MODIFIED' | 'DELETED';
|
|
105
162
|
createdAt: string;
|
|
106
163
|
updatedAt: string | null;
|
|
164
|
+
deletedAt?: string | null;
|
|
165
|
+
version?: number;
|
|
107
166
|
};
|
|
108
167
|
```
|
|
109
168
|
|
|
@@ -124,16 +183,79 @@ const statement = {
|
|
|
124
183
|
isLocked: boolean;
|
|
125
184
|
createdAt: string;
|
|
126
185
|
updatedAt: string | null;
|
|
186
|
+
deletedAt?: string | null;
|
|
187
|
+
version?: number;
|
|
127
188
|
};
|
|
128
189
|
```
|
|
129
190
|
|
|
191
|
+
### TransactionSplit
|
|
192
|
+
|
|
193
|
+
Validates splits within a transaction.
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
const transactionSplit = {
|
|
197
|
+
id: string;
|
|
198
|
+
transactionId: string;
|
|
199
|
+
amount: number;
|
|
200
|
+
categoryId: string | null;
|
|
201
|
+
description: string | null;
|
|
202
|
+
createdAt: string;
|
|
203
|
+
updatedAt: string | null;
|
|
204
|
+
deletedAt?: string | null;
|
|
205
|
+
version?: number;
|
|
206
|
+
};
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### LucaSchema
|
|
210
|
+
|
|
211
|
+
Validates the full ledger export.
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
const lucaSchema = {
|
|
215
|
+
schemaVersion: string;
|
|
216
|
+
categories: Category[];
|
|
217
|
+
accounts: Account[];
|
|
218
|
+
statements: Statement[];
|
|
219
|
+
recurringTransactions: RecurringTransaction[];
|
|
220
|
+
recurringTransactionEvents: RecurringTransactionEvent[];
|
|
221
|
+
transactions: Transaction[];
|
|
222
|
+
transactionSplits: TransactionSplit[];
|
|
223
|
+
};
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Validator Utilities
|
|
227
|
+
|
|
228
|
+
This module exports helper utilities to inspect schemas and validate data:
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
import {
|
|
232
|
+
validate,
|
|
233
|
+
validateCollection,
|
|
234
|
+
getValidFields,
|
|
235
|
+
getRequiredFields,
|
|
236
|
+
stripInvalidFields,
|
|
237
|
+
schemas,
|
|
238
|
+
enums,
|
|
239
|
+
LucaSchemas
|
|
240
|
+
} from '@luca-financial/luca-schema';
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
- `validate(schemaKey, data)` → `{ valid: boolean, errors: AjvError[] }`
|
|
244
|
+
- `validateCollection(schemaKey, array)` → `{ valid: boolean, errors: [{ index, entity, errors }] }`
|
|
245
|
+
- `getValidFields(schemaKey)` → `Set<string>` of all fields (includes common fields when applicable)
|
|
246
|
+
- `getRequiredFields(schemaKey)` → `Set<string>` of required fields (includes common required fields)
|
|
247
|
+
- `stripInvalidFields(schemaKey, data)` → new object with only schema-defined keys
|
|
248
|
+
- `schemas` → map of schema JSON objects
|
|
249
|
+
- `enums` → enum definitions (including `LucaSchemas` keys)
|
|
250
|
+
- `LucaSchemas` → names for schema keys (e.g., `LucaSchemas.TRANSACTION`)
|
|
251
|
+
|
|
130
252
|
## Development
|
|
131
253
|
|
|
132
254
|
```bash
|
|
133
|
-
pnpm build
|
|
134
|
-
pnpm test
|
|
135
|
-
pnpm lint
|
|
136
|
-
pnpm type-check
|
|
255
|
+
pnpm build
|
|
256
|
+
pnpm test
|
|
257
|
+
pnpm lint
|
|
258
|
+
pnpm type-check
|
|
137
259
|
```
|
|
138
260
|
|
|
139
261
|
## Contributing
|