@luca-financial/luca-schema 2.3.0 → 2.3.1
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/dist/esm/index.d.ts +2 -32
- package/dist/esm/index.js +1 -3
- package/dist/esm/lucaValidator.js +0 -34
- package/dist/esm/schemas/account.json +1 -0
- package/dist/esm/schemas/category.json +1 -0
- package/dist/esm/schemas/recurringTransaction.json +6 -0
- package/dist/esm/schemas/transaction.json +2 -10
- package/dist/esm/schemas/transactionSplit.json +1 -5
- package/dist/index.d.ts +2 -32
- package/package.json +1 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -405,7 +405,7 @@ export type IsLocked = boolean;
|
|
|
405
405
|
*/
|
|
406
406
|
export type RecurringTransaction = Common3 & {
|
|
407
407
|
accountId: AccountID1;
|
|
408
|
-
categoryId
|
|
408
|
+
categoryId: CategoryID;
|
|
409
409
|
amount: Amount;
|
|
410
410
|
description: Description1;
|
|
411
411
|
/**
|
|
@@ -534,8 +534,6 @@ export type Transaction = Common5 & {
|
|
|
534
534
|
currency?: Currency;
|
|
535
535
|
amount: Amount1;
|
|
536
536
|
description: Description2;
|
|
537
|
-
memo?: Memo;
|
|
538
|
-
counterparty?: Counterparty;
|
|
539
537
|
categoryId?: CategoryID1;
|
|
540
538
|
statementId?: StatementID;
|
|
541
539
|
aggregationServiceId?: AggregationServiceID1;
|
|
@@ -602,14 +600,6 @@ export type Amount1 = number;
|
|
|
602
600
|
* Description of the transaction
|
|
603
601
|
*/
|
|
604
602
|
export type Description2 = string;
|
|
605
|
-
/**
|
|
606
|
-
* Additional notes for the transaction.
|
|
607
|
-
*/
|
|
608
|
-
export type Memo = string | null;
|
|
609
|
-
/**
|
|
610
|
-
* Name of the other party (merchant/payor/payee).
|
|
611
|
-
*/
|
|
612
|
-
export type Counterparty = string | null;
|
|
613
603
|
/**
|
|
614
604
|
* Category UUID for this transaction
|
|
615
605
|
*/
|
|
@@ -630,7 +620,6 @@ export type TransactionSplit = Common6 & {
|
|
|
630
620
|
amount: Amount2;
|
|
631
621
|
categoryId: CategoryID2;
|
|
632
622
|
description?: Description3;
|
|
633
|
-
memo?: Memo1;
|
|
634
623
|
};
|
|
635
624
|
/**
|
|
636
625
|
* UUID for the item
|
|
@@ -668,10 +657,6 @@ export type CategoryID2 = string | null;
|
|
|
668
657
|
* Optional description for the split.
|
|
669
658
|
*/
|
|
670
659
|
export type Description3 = string | null;
|
|
671
|
-
/**
|
|
672
|
-
* Additional notes for this split.
|
|
673
|
-
*/
|
|
674
|
-
export type Memo1 = string | null;
|
|
675
660
|
|
|
676
661
|
/**
|
|
677
662
|
* Schema for the luca ledger
|
|
@@ -786,7 +771,7 @@ export interface Common6 {
|
|
|
786
771
|
*/
|
|
787
772
|
export type RecurringTransaction = Common & {
|
|
788
773
|
accountId: AccountID;
|
|
789
|
-
categoryId
|
|
774
|
+
categoryId: CategoryID;
|
|
790
775
|
amount: Amount;
|
|
791
776
|
description: Description;
|
|
792
777
|
/**
|
|
@@ -1016,8 +1001,6 @@ export type Transaction = Common & {
|
|
|
1016
1001
|
currency?: Currency;
|
|
1017
1002
|
amount: Amount;
|
|
1018
1003
|
description: Description;
|
|
1019
|
-
memo?: Memo;
|
|
1020
|
-
counterparty?: Counterparty;
|
|
1021
1004
|
categoryId?: CategoryID;
|
|
1022
1005
|
statementId?: StatementID;
|
|
1023
1006
|
aggregationServiceId?: AggregationServiceID;
|
|
@@ -1084,14 +1067,6 @@ export type Amount = number;
|
|
|
1084
1067
|
* Description of the transaction
|
|
1085
1068
|
*/
|
|
1086
1069
|
export type Description = string;
|
|
1087
|
-
/**
|
|
1088
|
-
* Additional notes for the transaction.
|
|
1089
|
-
*/
|
|
1090
|
-
export type Memo = string | null;
|
|
1091
|
-
/**
|
|
1092
|
-
* Name of the other party (merchant/payor/payee).
|
|
1093
|
-
*/
|
|
1094
|
-
export type Counterparty = string | null;
|
|
1095
1070
|
/**
|
|
1096
1071
|
* Category UUID for this transaction
|
|
1097
1072
|
*/
|
|
@@ -1124,7 +1099,6 @@ export type TransactionSplit = Common & {
|
|
|
1124
1099
|
amount: Amount;
|
|
1125
1100
|
categoryId: CategoryID;
|
|
1126
1101
|
description?: Description;
|
|
1127
|
-
memo?: Memo;
|
|
1128
1102
|
};
|
|
1129
1103
|
/**
|
|
1130
1104
|
* UUID for the item
|
|
@@ -1162,10 +1136,6 @@ export type CategoryID = string | null;
|
|
|
1162
1136
|
* Optional description for the split.
|
|
1163
1137
|
*/
|
|
1164
1138
|
export type Description = string | null;
|
|
1165
|
-
/**
|
|
1166
|
-
* Additional notes for this split.
|
|
1167
|
-
*/
|
|
1168
|
-
export type Memo = string | null;
|
|
1169
1139
|
|
|
1170
1140
|
/**
|
|
1171
1141
|
* Common properties for all schemas
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as schemaIndex from './schemas/index.js';
|
|
2
2
|
import { enums, LucaSchemas } from './enums.js';
|
|
3
3
|
import {
|
|
4
|
-
applyDefaults,
|
|
5
4
|
getRequiredFields,
|
|
6
5
|
getValidFields,
|
|
7
6
|
stripInvalidFields,
|
|
@@ -29,7 +28,6 @@ export {
|
|
|
29
28
|
validateCollection,
|
|
30
29
|
getValidFields,
|
|
31
30
|
getRequiredFields,
|
|
32
|
-
stripInvalidFields
|
|
33
|
-
applyDefaults
|
|
31
|
+
stripInvalidFields
|
|
34
32
|
};
|
|
35
33
|
export default schemas;
|
|
@@ -89,14 +89,6 @@ function isPlainObject(value) {
|
|
|
89
89
|
return proto === Object.prototype || proto === null;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function cloneDefault(value) {
|
|
93
|
-
if (typeof structuredClone === 'function') return structuredClone(value);
|
|
94
|
-
if (value && typeof value === 'object') {
|
|
95
|
-
return JSON.parse(JSON.stringify(value));
|
|
96
|
-
}
|
|
97
|
-
return value;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
92
|
export function validate(schemaKey, data) {
|
|
101
93
|
const ajv = getValidator();
|
|
102
94
|
const schema = getSchema(schemaKey);
|
|
@@ -157,32 +149,6 @@ export function stripInvalidFields(schemaKey, data) {
|
|
|
157
149
|
return cleaned;
|
|
158
150
|
}
|
|
159
151
|
|
|
160
|
-
/**
|
|
161
|
-
* Returns a new object with top-level schema defaults applied for missing fields.
|
|
162
|
-
* @param {string} schemaKey
|
|
163
|
-
* @param {object | null | undefined} data
|
|
164
|
-
* @returns {object}
|
|
165
|
-
*/
|
|
166
|
-
export function applyDefaults(schemaKey, data) {
|
|
167
|
-
if (data === null || data === undefined) return {};
|
|
168
|
-
if (!isPlainObject(data)) {
|
|
169
|
-
throw new TypeError('Expected a plain object for data');
|
|
170
|
-
}
|
|
171
|
-
const schema = getSchema(schemaKey);
|
|
172
|
-
const properties = getSchemaProperties(schema);
|
|
173
|
-
const next = { ...data };
|
|
174
|
-
for (const [key, definition] of Object.entries(properties)) {
|
|
175
|
-
if (next[key] !== undefined) continue;
|
|
176
|
-
if (
|
|
177
|
-
definition &&
|
|
178
|
-
Object.prototype.hasOwnProperty.call(definition, 'default')
|
|
179
|
-
) {
|
|
180
|
-
next[key] = cloneDefault(definition.default);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return next;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
152
|
/**
|
|
187
153
|
* Validates an array of entities efficiently and returns structured errors.
|
|
188
154
|
* @param {string} schemaKey
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"type": ["string", "null"],
|
|
31
31
|
"title": "Parent Category ID",
|
|
32
32
|
"format": "uuid",
|
|
33
|
+
"default": null,
|
|
33
34
|
"description": "The identifier of the parent category, if any. Null if the category is top-level. Parents must be top-level (no deeper than two levels; enforced outside JSON Schema)."
|
|
34
35
|
}
|
|
35
36
|
},
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"type": ["string", "null"],
|
|
21
21
|
"title": "Category ID",
|
|
22
22
|
"format": "uuid",
|
|
23
|
+
"default": null,
|
|
23
24
|
"description": "Category identifier for organizing the transaction. Can be null if not categorized."
|
|
24
25
|
},
|
|
25
26
|
"amount": {
|
|
@@ -36,18 +37,21 @@
|
|
|
36
37
|
"type": "string",
|
|
37
38
|
"title": "Transaction Frequency",
|
|
38
39
|
"$ref": "./enums.json#/$defs/RecurringTransactionFrequency",
|
|
40
|
+
"default": "MONTH",
|
|
39
41
|
"description": "Defines the base unit of time for the repetition."
|
|
40
42
|
},
|
|
41
43
|
"interval": {
|
|
42
44
|
"type": "integer",
|
|
43
45
|
"title": "Frequency Interval",
|
|
44
46
|
"minimum": 1,
|
|
47
|
+
"default": 1,
|
|
45
48
|
"description": "Specifies the number of frequency units between each occurrence (e.g., every 2 weeks)."
|
|
46
49
|
},
|
|
47
50
|
"occurrences": {
|
|
48
51
|
"type": ["integer", "null"],
|
|
49
52
|
"title": "Total Occurrences",
|
|
50
53
|
"minimum": 1,
|
|
54
|
+
"default": null,
|
|
51
55
|
"description": "The total number of times the transaction should occur. Can be null if not specified."
|
|
52
56
|
},
|
|
53
57
|
"startOn": {
|
|
@@ -66,11 +70,13 @@
|
|
|
66
70
|
"type": "string",
|
|
67
71
|
"title": "Recurring Transaction State",
|
|
68
72
|
"$ref": "./enums.json#/$defs/RecurringTransactionState",
|
|
73
|
+
"default": "ACTIVE",
|
|
69
74
|
"description": "Current state of the recurring transaction series."
|
|
70
75
|
}
|
|
71
76
|
},
|
|
72
77
|
"required": [
|
|
73
78
|
"accountId",
|
|
79
|
+
"categoryId",
|
|
74
80
|
"amount",
|
|
75
81
|
"description",
|
|
76
82
|
"frequency",
|
|
@@ -52,20 +52,11 @@
|
|
|
52
52
|
"minLength": 1,
|
|
53
53
|
"description": "Description of the transaction"
|
|
54
54
|
},
|
|
55
|
-
"memo": {
|
|
56
|
-
"type": ["string", "null"],
|
|
57
|
-
"title": "Memo",
|
|
58
|
-
"description": "Additional notes for the transaction."
|
|
59
|
-
},
|
|
60
|
-
"counterparty": {
|
|
61
|
-
"type": ["string", "null"],
|
|
62
|
-
"title": "Counterparty",
|
|
63
|
-
"description": "Name of the other party (merchant/payor/payee)."
|
|
64
|
-
},
|
|
65
55
|
"categoryId": {
|
|
66
56
|
"type": ["string", "null"],
|
|
67
57
|
"title": "Category ID",
|
|
68
58
|
"format": "uuid",
|
|
59
|
+
"default": null,
|
|
69
60
|
"description": "Category UUID for this transaction"
|
|
70
61
|
},
|
|
71
62
|
"statementId": {
|
|
@@ -83,6 +74,7 @@
|
|
|
83
74
|
"type": "string",
|
|
84
75
|
"title": "Transaction State",
|
|
85
76
|
"$ref": "./enums.json#/$defs/TransactionState",
|
|
77
|
+
"default": "PLANNED",
|
|
86
78
|
"description": "The current state of the transaction."
|
|
87
79
|
}
|
|
88
80
|
},
|
|
@@ -26,17 +26,13 @@
|
|
|
26
26
|
"type": ["string", "null"],
|
|
27
27
|
"title": "Category ID",
|
|
28
28
|
"format": "uuid",
|
|
29
|
+
"default": null,
|
|
29
30
|
"description": "The identifier of the category for this split."
|
|
30
31
|
},
|
|
31
32
|
"description": {
|
|
32
33
|
"type": ["string", "null"],
|
|
33
34
|
"title": "Description",
|
|
34
35
|
"description": "Optional description for the split."
|
|
35
|
-
},
|
|
36
|
-
"memo": {
|
|
37
|
-
"type": ["string", "null"],
|
|
38
|
-
"title": "Memo",
|
|
39
|
-
"description": "Additional notes for this split."
|
|
40
36
|
}
|
|
41
37
|
},
|
|
42
38
|
"required": ["transactionId", "amount", "categoryId"]
|
package/dist/index.d.ts
CHANGED
|
@@ -405,7 +405,7 @@ export type IsLocked = boolean;
|
|
|
405
405
|
*/
|
|
406
406
|
export type RecurringTransaction = Common3 & {
|
|
407
407
|
accountId: AccountID1;
|
|
408
|
-
categoryId
|
|
408
|
+
categoryId: CategoryID;
|
|
409
409
|
amount: Amount;
|
|
410
410
|
description: Description1;
|
|
411
411
|
/**
|
|
@@ -534,8 +534,6 @@ export type Transaction = Common5 & {
|
|
|
534
534
|
currency?: Currency;
|
|
535
535
|
amount: Amount1;
|
|
536
536
|
description: Description2;
|
|
537
|
-
memo?: Memo;
|
|
538
|
-
counterparty?: Counterparty;
|
|
539
537
|
categoryId?: CategoryID1;
|
|
540
538
|
statementId?: StatementID;
|
|
541
539
|
aggregationServiceId?: AggregationServiceID1;
|
|
@@ -602,14 +600,6 @@ export type Amount1 = number;
|
|
|
602
600
|
* Description of the transaction
|
|
603
601
|
*/
|
|
604
602
|
export type Description2 = string;
|
|
605
|
-
/**
|
|
606
|
-
* Additional notes for the transaction.
|
|
607
|
-
*/
|
|
608
|
-
export type Memo = string | null;
|
|
609
|
-
/**
|
|
610
|
-
* Name of the other party (merchant/payor/payee).
|
|
611
|
-
*/
|
|
612
|
-
export type Counterparty = string | null;
|
|
613
603
|
/**
|
|
614
604
|
* Category UUID for this transaction
|
|
615
605
|
*/
|
|
@@ -630,7 +620,6 @@ export type TransactionSplit = Common6 & {
|
|
|
630
620
|
amount: Amount2;
|
|
631
621
|
categoryId: CategoryID2;
|
|
632
622
|
description?: Description3;
|
|
633
|
-
memo?: Memo1;
|
|
634
623
|
};
|
|
635
624
|
/**
|
|
636
625
|
* UUID for the item
|
|
@@ -668,10 +657,6 @@ export type CategoryID2 = string | null;
|
|
|
668
657
|
* Optional description for the split.
|
|
669
658
|
*/
|
|
670
659
|
export type Description3 = string | null;
|
|
671
|
-
/**
|
|
672
|
-
* Additional notes for this split.
|
|
673
|
-
*/
|
|
674
|
-
export type Memo1 = string | null;
|
|
675
660
|
|
|
676
661
|
/**
|
|
677
662
|
* Schema for the luca ledger
|
|
@@ -786,7 +771,7 @@ export interface Common6 {
|
|
|
786
771
|
*/
|
|
787
772
|
export type RecurringTransaction = Common & {
|
|
788
773
|
accountId: AccountID;
|
|
789
|
-
categoryId
|
|
774
|
+
categoryId: CategoryID;
|
|
790
775
|
amount: Amount;
|
|
791
776
|
description: Description;
|
|
792
777
|
/**
|
|
@@ -1016,8 +1001,6 @@ export type Transaction = Common & {
|
|
|
1016
1001
|
currency?: Currency;
|
|
1017
1002
|
amount: Amount;
|
|
1018
1003
|
description: Description;
|
|
1019
|
-
memo?: Memo;
|
|
1020
|
-
counterparty?: Counterparty;
|
|
1021
1004
|
categoryId?: CategoryID;
|
|
1022
1005
|
statementId?: StatementID;
|
|
1023
1006
|
aggregationServiceId?: AggregationServiceID;
|
|
@@ -1084,14 +1067,6 @@ export type Amount = number;
|
|
|
1084
1067
|
* Description of the transaction
|
|
1085
1068
|
*/
|
|
1086
1069
|
export type Description = string;
|
|
1087
|
-
/**
|
|
1088
|
-
* Additional notes for the transaction.
|
|
1089
|
-
*/
|
|
1090
|
-
export type Memo = string | null;
|
|
1091
|
-
/**
|
|
1092
|
-
* Name of the other party (merchant/payor/payee).
|
|
1093
|
-
*/
|
|
1094
|
-
export type Counterparty = string | null;
|
|
1095
1070
|
/**
|
|
1096
1071
|
* Category UUID for this transaction
|
|
1097
1072
|
*/
|
|
@@ -1124,7 +1099,6 @@ export type TransactionSplit = Common & {
|
|
|
1124
1099
|
amount: Amount;
|
|
1125
1100
|
categoryId: CategoryID;
|
|
1126
1101
|
description?: Description;
|
|
1127
|
-
memo?: Memo;
|
|
1128
1102
|
};
|
|
1129
1103
|
/**
|
|
1130
1104
|
* UUID for the item
|
|
@@ -1162,10 +1136,6 @@ export type CategoryID = string | null;
|
|
|
1162
1136
|
* Optional description for the split.
|
|
1163
1137
|
*/
|
|
1164
1138
|
export type Description = string | null;
|
|
1165
|
-
/**
|
|
1166
|
-
* Additional notes for this split.
|
|
1167
|
-
*/
|
|
1168
|
-
export type Memo = string | null;
|
|
1169
1139
|
|
|
1170
1140
|
/**
|
|
1171
1141
|
* Common properties for all schemas
|