@luca-financial/luca-schema 1.2.2 → 1.3.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/CHANGELOG.md +45 -0
- package/README.md +124 -14
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/schemas/category.json +63 -0
- package/dist/cjs/schemas/common.json +30 -0
- package/dist/cjs/schemas/entity.json +44 -0
- package/dist/cjs/schemas/index.ts +30 -0
- package/dist/cjs/schemas/lucaSchema.json +61 -0
- package/dist/cjs/schemas/recurringTransaction.json +86 -0
- package/dist/cjs/schemas/recurringTransactionEvent.json +58 -0
- package/dist/cjs/schemas/transaction.json +76 -0
- package/dist/enums.d.ts +12 -0
- package/dist/enums.js +68 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/schemas/category.json +63 -0
- package/dist/esm/schemas/common.json +30 -0
- package/dist/esm/schemas/entity.json +44 -0
- package/dist/esm/schemas/index.ts +30 -0
- package/dist/esm/schemas/lucaSchema.json +61 -0
- package/dist/esm/schemas/recurringTransaction.json +86 -0
- package/dist/esm/schemas/recurringTransactionEvent.json +58 -0
- package/dist/esm/schemas/transaction.json +76 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/lucaValidator.d.ts +54 -0
- package/dist/lucaValidator.js +34 -0
- package/dist/schemas/category.json +63 -0
- package/dist/schemas/common.json +30 -0
- package/dist/schemas/entity.json +44 -0
- package/dist/schemas/index.d.ts +12 -0
- package/dist/schemas/index.js +17 -0
- package/dist/schemas/lucaSchema.json +61 -0
- package/dist/schemas/recurringTransaction.json +86 -0
- package/dist/schemas/recurringTransactionEvent.json +58 -0
- package/dist/schemas/transaction.json +76 -0
- package/dist/tests/test-utils.d.ts +37 -0
- package/dist/tests/test-utils.js +115 -0
- package/dist/types/enums.d.ts +8 -0
- package/dist/types/enums.js +1 -0
- package/package.json +56 -7
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.3.0] - 2025-10-11
|
|
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
|
|
31
|
+
|
|
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
|
|
43
|
+
|
|
44
|
+
- Legacy JavaScript implementation
|
|
45
|
+
- Basic schema validation functionality
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# LucaSchema
|
|
2
2
|
|
|
3
|
-
Schema validation library for the Luca Ledger application.
|
|
3
|
+
Schema validation library for the Luca Ledger application. Provides type-safe validation for financial transactions, entities, and related data structures. Supports TypeScript.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -10,32 +10,129 @@ npm install @luca-financial/luca-schema
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
```
|
|
14
|
-
import { lucaValidator, enums } from '@luca-financial/luca-schema';
|
|
13
|
+
```typescript
|
|
14
|
+
import { lucaValidator, enums, schemas } from '@luca-financial/luca-schema';
|
|
15
15
|
|
|
16
16
|
// Validate a transaction
|
|
17
17
|
const validateTransaction = lucaValidator.getSchema('transaction');
|
|
18
|
+
const transactionData = {
|
|
19
|
+
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,
|
|
24
|
+
date: '2024-01-01',
|
|
25
|
+
description: 'Test transaction',
|
|
26
|
+
transactionState: enums.TransactionStateEnum.COMPLETED,
|
|
27
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
28
|
+
updatedAt: null
|
|
29
|
+
};
|
|
30
|
+
|
|
18
31
|
const isValid = validateTransaction(transactionData);
|
|
19
32
|
|
|
20
33
|
if (!isValid) {
|
|
21
34
|
console.error('Validation errors:', validateTransaction.errors);
|
|
22
35
|
}
|
|
23
36
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
// Alternative: Use schemas directly with the validate method
|
|
38
|
+
const isValidDirect = lucaValidator.validate(
|
|
39
|
+
schemas.transaction,
|
|
40
|
+
transactionData
|
|
41
|
+
);
|
|
29
42
|
```
|
|
30
43
|
|
|
31
44
|
## Available Schemas
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
### Transaction
|
|
47
|
+
|
|
48
|
+
Validates financial transactions with properties like amount, date, and state.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const transaction = {
|
|
52
|
+
id: string;
|
|
53
|
+
payorId: string;
|
|
54
|
+
payeeId: string;
|
|
55
|
+
categoryId: string | null;
|
|
56
|
+
amount: number;
|
|
57
|
+
date: string;
|
|
58
|
+
description: string;
|
|
59
|
+
transactionState: TransactionState;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
updatedAt: string | null;
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### RecurringTransaction
|
|
66
|
+
|
|
67
|
+
Validates recurring transaction templates with frequency and interval settings.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const recurringTransaction = {
|
|
71
|
+
id: string;
|
|
72
|
+
payorId: string;
|
|
73
|
+
payeeId: string;
|
|
74
|
+
categoryId: string | null;
|
|
75
|
+
amount: number;
|
|
76
|
+
description: string;
|
|
77
|
+
frequency: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
|
|
78
|
+
interval: number;
|
|
79
|
+
occurrences: number | null;
|
|
80
|
+
startOn: string;
|
|
81
|
+
endOn: string | null;
|
|
82
|
+
recurringTransactionState: 'ACTIVE' | 'PAUSED' | 'COMPLETED' | 'CANCELLED';
|
|
83
|
+
createdAt: string;
|
|
84
|
+
updatedAt: string | null;
|
|
85
|
+
};
|
|
86
|
+
```
|
|
87
|
+
|
|
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
|
+
### Category
|
|
105
|
+
|
|
106
|
+
Validates transaction categories with optional parent relationships.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const category = {
|
|
110
|
+
id: string;
|
|
111
|
+
name: string;
|
|
112
|
+
description: string | null;
|
|
113
|
+
parentId: string | null;
|
|
114
|
+
defaultCategoryId: string | null;
|
|
115
|
+
categoryType: 'DEFAULT' | 'MODIFIED' | 'CUSTOM';
|
|
116
|
+
createdAt: string;
|
|
117
|
+
updatedAt: string | null;
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### RecurringTransactionEvent
|
|
122
|
+
|
|
123
|
+
Validates events that track changes to recurring transactions.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
const recurringTransactionEvent = {
|
|
127
|
+
id: string;
|
|
128
|
+
transactionId: string;
|
|
129
|
+
recurringTransactionId: string;
|
|
130
|
+
expectedDate: string;
|
|
131
|
+
eventState: 'MODIFIED' | 'DELETED';
|
|
132
|
+
createdAt: string;
|
|
133
|
+
updatedAt: string | null;
|
|
134
|
+
};
|
|
135
|
+
```
|
|
39
136
|
|
|
40
137
|
## Development
|
|
41
138
|
|
|
@@ -43,4 +140,17 @@ const transactionState = enums.TransactionStateEnum.COMPLETED;
|
|
|
43
140
|
yarn build # Build the library
|
|
44
141
|
yarn test # Run tests
|
|
45
142
|
yarn lint # Check code style
|
|
143
|
+
yarn type-check # Check TypeScript types
|
|
46
144
|
```
|
|
145
|
+
|
|
146
|
+
## Contributing
|
|
147
|
+
|
|
148
|
+
1. Fork the repository
|
|
149
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
150
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
151
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
152
|
+
5. Open a Pull Request
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/category.json",
|
|
4
|
+
"title": "Category",
|
|
5
|
+
"description": "Defines the schema for categories used to organize transactions within a ledger application. Categories can be default, modified, or custom, providing flexibility in categorization.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"allOf": [
|
|
8
|
+
{
|
|
9
|
+
"$ref": "./common.json"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"name": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"title": "Category Name",
|
|
16
|
+
"description": "The name of the category."
|
|
17
|
+
},
|
|
18
|
+
"description": {
|
|
19
|
+
"type": ["string", "null"],
|
|
20
|
+
"title": "Description",
|
|
21
|
+
"description": "A description of the category, providing additional context. Can be null if not specified."
|
|
22
|
+
},
|
|
23
|
+
"parentId": {
|
|
24
|
+
"type": ["string", "null"],
|
|
25
|
+
"title": "Parent Category ID",
|
|
26
|
+
"format": "uuid",
|
|
27
|
+
"description": "The identifier of the parent category, if any. Null if the category is top-level."
|
|
28
|
+
},
|
|
29
|
+
"defaultCategoryId": {
|
|
30
|
+
"type": ["string", "null"],
|
|
31
|
+
"title": "Default Category ID",
|
|
32
|
+
"format": "uuid",
|
|
33
|
+
"description": "For custom categories, this indicates the default category from which this was derived. Required if categoryType is MODIFIED."
|
|
34
|
+
},
|
|
35
|
+
"categoryType": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"title": "Category Type",
|
|
38
|
+
"enum": ["DEFAULT", "MODIFIED", "CUSTOM"],
|
|
39
|
+
"description": "The type of the category, indicating whether it is a default, modified, or custom category."
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"required": [
|
|
43
|
+
"name",
|
|
44
|
+
"description",
|
|
45
|
+
"parentId",
|
|
46
|
+
"defaultCategoryId",
|
|
47
|
+
"categoryType"
|
|
48
|
+
],
|
|
49
|
+
"if": {
|
|
50
|
+
"properties": {
|
|
51
|
+
"categoryType": {
|
|
52
|
+
"const": "MODIFIED"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"then": {
|
|
57
|
+
"properties": {
|
|
58
|
+
"defaultCategoryId": {
|
|
59
|
+
"type": "string"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/common.json",
|
|
4
|
+
"title": "Common",
|
|
5
|
+
"description": "Common properties for all schemas",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["id", "createdAt", "updatedAt"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"title": "ID",
|
|
12
|
+
"format": "uuid",
|
|
13
|
+
"readOnly": true,
|
|
14
|
+
"description": "UUID for the item"
|
|
15
|
+
},
|
|
16
|
+
"createdAt": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"title": "Date Created",
|
|
19
|
+
"format": "date-time",
|
|
20
|
+
"readOnly": true,
|
|
21
|
+
"description": "The timestamp of the creation of the item"
|
|
22
|
+
},
|
|
23
|
+
"updatedAt": {
|
|
24
|
+
"type": ["string", "null"],
|
|
25
|
+
"title": "Last Updated",
|
|
26
|
+
"format": "date-time",
|
|
27
|
+
"description": "The timestamp of the last update or null if the item has not been updated yet"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/entity.json",
|
|
4
|
+
"title": "Entity",
|
|
5
|
+
"description": "Defines the schema for entities within the application, categorizing them into specific, predefined types such as account, retailer, business, individual, utility, and government. This schema includes basic details and timestamps for creation and updates.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["name", "description", "entityType", "entityStatus"],
|
|
8
|
+
"allOf": [
|
|
9
|
+
{
|
|
10
|
+
"$ref": "./common.json"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"title": "Entity Name",
|
|
17
|
+
"description": "The name of the entity."
|
|
18
|
+
},
|
|
19
|
+
"description": {
|
|
20
|
+
"type": ["string", "null"],
|
|
21
|
+
"title": "Description",
|
|
22
|
+
"description": "A description of the entity. This can be null if no description is provided."
|
|
23
|
+
},
|
|
24
|
+
"entityType": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"title": "Entity Type",
|
|
27
|
+
"enum": [
|
|
28
|
+
"ACCOUNT",
|
|
29
|
+
"RETAILER",
|
|
30
|
+
"SERVICE",
|
|
31
|
+
"INDIVIDUAL",
|
|
32
|
+
"UTILITY",
|
|
33
|
+
"GOVERNMENT"
|
|
34
|
+
],
|
|
35
|
+
"description": "The type of the entity, indicating its role or classification within the application. Controlled to specific predefined options for consistency and integrity."
|
|
36
|
+
},
|
|
37
|
+
"entityStatus": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"title": "Entity Status",
|
|
40
|
+
"enum": ["ACTIVE", "INACTIVE", "SUSPENDED", "DELETED", "CLOSED"],
|
|
41
|
+
"description": "The status of the entity, indicating whether it is active, inactive, suspended, or deleted. Controlled to specific predefined options for consistency and integrity."
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AnySchema } from 'ajv';
|
|
2
|
+
import category from './category.json';
|
|
3
|
+
import common from './common.json';
|
|
4
|
+
import entity from './entity.json';
|
|
5
|
+
import lucaSchema from './lucaSchema.json';
|
|
6
|
+
import recurringTransaction from './recurringTransaction.json';
|
|
7
|
+
import recurringTransactionEvent from './recurringTransactionEvent.json';
|
|
8
|
+
import transaction from './transaction.json';
|
|
9
|
+
|
|
10
|
+
export interface Schemas {
|
|
11
|
+
category: AnySchema;
|
|
12
|
+
common: AnySchema;
|
|
13
|
+
entity: AnySchema;
|
|
14
|
+
lucaSchema: AnySchema;
|
|
15
|
+
recurringTransaction: AnySchema;
|
|
16
|
+
recurringTransactionEvent: AnySchema;
|
|
17
|
+
transaction: AnySchema;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const schemas: Schemas = {
|
|
21
|
+
category,
|
|
22
|
+
common,
|
|
23
|
+
entity,
|
|
24
|
+
lucaSchema,
|
|
25
|
+
recurringTransaction,
|
|
26
|
+
recurringTransactionEvent,
|
|
27
|
+
transaction
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default schemas;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/lucaSchema.json",
|
|
4
|
+
"title": "Luca Schema",
|
|
5
|
+
"description": "Schema for the luca ledger",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"schemaVersion",
|
|
9
|
+
"categories",
|
|
10
|
+
"entities",
|
|
11
|
+
"recurringTransactions",
|
|
12
|
+
"recurringTransactionEvents",
|
|
13
|
+
"transactions"
|
|
14
|
+
],
|
|
15
|
+
"properties": {
|
|
16
|
+
"schemaVersion": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Schema version of the luca ledger"
|
|
19
|
+
},
|
|
20
|
+
"categories": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"description": "List of categories",
|
|
23
|
+
"uniqueItems": true,
|
|
24
|
+
"items": {
|
|
25
|
+
"$ref": "./category.json"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"entities": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"description": "List of entities",
|
|
31
|
+
"uniqueItems": true,
|
|
32
|
+
"items": {
|
|
33
|
+
"$ref": "./entity.json"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"recurringTransactions": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"description": "List of recurring transactions",
|
|
39
|
+
"uniqueItems": true,
|
|
40
|
+
"items": {
|
|
41
|
+
"$ref": "./recurringTransaction.json"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"recurringTransactionEvents": {
|
|
45
|
+
"type": "array",
|
|
46
|
+
"description": "List of recurring transaction events",
|
|
47
|
+
"uniqueItems": true,
|
|
48
|
+
"items": {
|
|
49
|
+
"$ref": "./recurringTransactionEvent.json"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"transactions": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"description": "List of transactions",
|
|
55
|
+
"uniqueItems": true,
|
|
56
|
+
"items": {
|
|
57
|
+
"$ref": "./transaction.json"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/recurringTransaction.json",
|
|
4
|
+
"title": "Recurring Transaction",
|
|
5
|
+
"description": "Defines recurring financial transactions within the application, including their scheduling, frequency, interval, and optional constraints like total occurrences or an end date.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"allOf": [
|
|
8
|
+
{
|
|
9
|
+
"$ref": "./common.json"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"payorId": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"title": "Payor ID",
|
|
16
|
+
"format": "uuid",
|
|
17
|
+
"description": "Identifier for the payor in the transaction."
|
|
18
|
+
},
|
|
19
|
+
"payeeId": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"title": "Payee ID",
|
|
22
|
+
"format": "uuid",
|
|
23
|
+
"description": "Identifier for the payee in the transaction."
|
|
24
|
+
},
|
|
25
|
+
"categoryId": {
|
|
26
|
+
"type": ["string", "null"],
|
|
27
|
+
"title": "Category ID",
|
|
28
|
+
"format": "uuid",
|
|
29
|
+
"description": "Category identifier for organizing the transaction. Can be null if not categorized."
|
|
30
|
+
},
|
|
31
|
+
"amount": {
|
|
32
|
+
"type": "number",
|
|
33
|
+
"title": "Amount",
|
|
34
|
+
"minimum": 0,
|
|
35
|
+
"multipleOf": 0.01,
|
|
36
|
+
"description": "The monetary value of the transaction."
|
|
37
|
+
},
|
|
38
|
+
"frequency": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"title": "Transaction Frequency",
|
|
41
|
+
"enum": ["DAY", "WEEK", "MONTH", "YEAR"],
|
|
42
|
+
"description": "Defines the base unit of time for the repetition."
|
|
43
|
+
},
|
|
44
|
+
"interval": {
|
|
45
|
+
"type": "integer",
|
|
46
|
+
"title": "Frequency Interval",
|
|
47
|
+
"minimum": 1,
|
|
48
|
+
"description": "Specifies the number of frequency units between each occurrence (e.g., every 2 weeks)."
|
|
49
|
+
},
|
|
50
|
+
"occurrences": {
|
|
51
|
+
"type": ["integer", "null"],
|
|
52
|
+
"title": "Total Occurrences",
|
|
53
|
+
"minimum": 1,
|
|
54
|
+
"description": "The total number of times the transaction should occur. Can be null if not specified."
|
|
55
|
+
},
|
|
56
|
+
"startOn": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"title": "Start Date",
|
|
59
|
+
"format": "date",
|
|
60
|
+
"description": "The date on which the recurring transaction series should begin."
|
|
61
|
+
},
|
|
62
|
+
"endOn": {
|
|
63
|
+
"type": ["string", "null"],
|
|
64
|
+
"title": "End Date",
|
|
65
|
+
"format": "date",
|
|
66
|
+
"description": "The date on which the recurring transaction series should end. Can be null."
|
|
67
|
+
},
|
|
68
|
+
"recurringTransactionState": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"title": "Recurring Transaction State",
|
|
71
|
+
"enum": ["ACTIVE", "PAUSED", "COMPLETED", "CANCELLED"],
|
|
72
|
+
"description": "Current state of the recurring transaction series."
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"required": [
|
|
76
|
+
"payorId",
|
|
77
|
+
"payeeId",
|
|
78
|
+
"amount",
|
|
79
|
+
"frequency",
|
|
80
|
+
"interval",
|
|
81
|
+
"occurrences",
|
|
82
|
+
"startOn",
|
|
83
|
+
"endOn",
|
|
84
|
+
"recurringTransactionState"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/recurringTransactionEvent.json",
|
|
4
|
+
"title": "Recurring Transaction Event",
|
|
5
|
+
"description": "Manages occurrences of recurring transactions, including tracking their modifications or logical deletions. 'transactionId' is required when an occurrence is modified to link it to an actual transaction.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"allOf": [
|
|
8
|
+
{
|
|
9
|
+
"$ref": "./common.json"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"transactionId": {
|
|
14
|
+
"type": ["string", "null"],
|
|
15
|
+
"title": "Associated Transaction ID",
|
|
16
|
+
"format": "uuid",
|
|
17
|
+
"description": "Identifier of the actual transaction, required if the occurrence is modified."
|
|
18
|
+
},
|
|
19
|
+
"recurringTransactionId": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"title": "Recurring Transaction ID",
|
|
22
|
+
"format": "uuid",
|
|
23
|
+
"description": "Identifier of the associated recurring transaction."
|
|
24
|
+
},
|
|
25
|
+
"expectedDate": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"title": "Expected Date",
|
|
28
|
+
"format": "date",
|
|
29
|
+
"description": "The date when the occurrence is expected."
|
|
30
|
+
},
|
|
31
|
+
"eventState": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"title": "Event State",
|
|
34
|
+
"enum": ["MODIFIED", "DELETED"],
|
|
35
|
+
"description": "State of the occurrence, indicating if it has been modified or logically deleted."
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"required": [
|
|
39
|
+
"transactionId",
|
|
40
|
+
"recurringTransactionId",
|
|
41
|
+
"expectedDate",
|
|
42
|
+
"eventState"
|
|
43
|
+
],
|
|
44
|
+
"if": {
|
|
45
|
+
"properties": {
|
|
46
|
+
"eventState": {
|
|
47
|
+
"const": "MODIFIED"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"then": {
|
|
52
|
+
"properties": {
|
|
53
|
+
"transactionId": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/transaction.json",
|
|
4
|
+
"title": "Transaction",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"allOf": [
|
|
7
|
+
{
|
|
8
|
+
"$ref": "./common.json"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"properties": {
|
|
12
|
+
"date": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"title": "Transaction Date",
|
|
15
|
+
"format": "date",
|
|
16
|
+
"description": "The date the transaction took place."
|
|
17
|
+
},
|
|
18
|
+
"payorId": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"title": "Payor ID",
|
|
21
|
+
"format": "uuid",
|
|
22
|
+
"description": "Identifier for the payor in the transaction."
|
|
23
|
+
},
|
|
24
|
+
"payeeId": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"title": "Payee ID",
|
|
27
|
+
"format": "uuid",
|
|
28
|
+
"description": "Identifier for the payee in the transaction."
|
|
29
|
+
},
|
|
30
|
+
"categoryId": {
|
|
31
|
+
"type": ["string", "null"],
|
|
32
|
+
"title": "Category ID",
|
|
33
|
+
"format": "uuid",
|
|
34
|
+
"description": "Category identifier for organizing the transaction. Can be null if not categorized."
|
|
35
|
+
},
|
|
36
|
+
"amount": {
|
|
37
|
+
"type": "number",
|
|
38
|
+
"title": "Amount",
|
|
39
|
+
"minimum": 0,
|
|
40
|
+
"multipleOf": 0.01,
|
|
41
|
+
"description": "The monetary value of the transaction."
|
|
42
|
+
},
|
|
43
|
+
"description": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"title": "Description",
|
|
46
|
+
"maxLength": 500,
|
|
47
|
+
"description": "A brief description of the transaction."
|
|
48
|
+
},
|
|
49
|
+
"transactionState": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"title": "Transaction State",
|
|
52
|
+
"enum": [
|
|
53
|
+
"PLANNED",
|
|
54
|
+
"SCHEDULED",
|
|
55
|
+
"PENDING",
|
|
56
|
+
"COMPLETED",
|
|
57
|
+
"CANCELLED",
|
|
58
|
+
"FAILED",
|
|
59
|
+
"DISPUTED",
|
|
60
|
+
"REFUNDED",
|
|
61
|
+
"TENTATIVE",
|
|
62
|
+
"UPCOMING",
|
|
63
|
+
"DELETED"
|
|
64
|
+
],
|
|
65
|
+
"description": "The current state of the transaction."
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"required": [
|
|
69
|
+
"date",
|
|
70
|
+
"payorId",
|
|
71
|
+
"payeeId",
|
|
72
|
+
"amount",
|
|
73
|
+
"description",
|
|
74
|
+
"transactionState"
|
|
75
|
+
]
|
|
76
|
+
}
|
package/dist/enums.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SchemaType, TransactionState, CategoryType, EntityType, EntityStatus, RecurringTransactionFrequency, RecurringTransactionState, RecurringTransactionEventStatus } from './types/enums';
|
|
2
|
+
declare const enums: {
|
|
3
|
+
readonly CategoryTypeEnum: Record<string, CategoryType>;
|
|
4
|
+
readonly EntityTypeEnum: Record<string, EntityType>;
|
|
5
|
+
readonly EntityStatusEnum: Record<string, EntityStatus>;
|
|
6
|
+
readonly RecurringTransactionFrequencyEnum: Record<string, RecurringTransactionFrequency>;
|
|
7
|
+
readonly RecurringTransactionStateEnum: Record<string, RecurringTransactionState>;
|
|
8
|
+
readonly RecurringTransactionEventStatusEnum: Record<string, RecurringTransactionEventStatus>;
|
|
9
|
+
readonly SchemasEnum: Record<string, SchemaType>;
|
|
10
|
+
readonly TransactionStateEnum: Record<string, TransactionState>;
|
|
11
|
+
};
|
|
12
|
+
export default enums;
|