@luca-financial/luca-schema 0.0.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/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/schemas/category.json +65 -0
- package/dist/cjs/schemas/entity.json +65 -0
- package/dist/cjs/schemas/index.js +25 -0
- package/dist/cjs/schemas/index.js.map +1 -0
- package/dist/cjs/schemas/lucaSchema.json +54 -0
- package/dist/cjs/schemas/recurringTransaction.json +90 -0
- package/dist/cjs/schemas/recurringTransactionEvent.json +57 -0
- package/dist/cjs/schemas/schema.json +24 -0
- package/dist/cjs/schemas/transaction.json +77 -0
- package/dist/cjs/validators.js +40 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/schemas/category.json +65 -0
- package/dist/esm/schemas/entity.json +65 -0
- package/dist/esm/schemas/index.js +19 -0
- package/dist/esm/schemas/lucaSchema.json +54 -0
- package/dist/esm/schemas/recurringTransaction.json +90 -0
- package/dist/esm/schemas/recurringTransactionEvent.json +57 -0
- package/dist/esm/schemas/schema.json +24 -0
- package/dist/esm/schemas/transaction.json +77 -0
- package/dist/esm/validators.js +28 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Luca Financial
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "schemas", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _schemas["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "validators", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _validators["default"];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _schemas = _interopRequireDefault(require("./schemas.js"));
|
|
19
|
+
var _validators = _interopRequireDefault(require("./validators"));
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "A unique identifier for the category."
|
|
11
|
+
},
|
|
12
|
+
"name": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The name of the category."
|
|
15
|
+
},
|
|
16
|
+
"description": {
|
|
17
|
+
"type": ["string", "null"],
|
|
18
|
+
"description": "A description of the category, providing additional context. Can be null if not specified."
|
|
19
|
+
},
|
|
20
|
+
"parentId": {
|
|
21
|
+
"type": ["string", "null"],
|
|
22
|
+
"description": "The identifier of the parent category, if any. Null if the category is top-level."
|
|
23
|
+
},
|
|
24
|
+
"defaultCategoryId": {
|
|
25
|
+
"type": ["string", "null"],
|
|
26
|
+
"description": "For custom categories, this indicates the default category from which this was derived. Required if categoryType is CUSTOM."
|
|
27
|
+
},
|
|
28
|
+
"categoryType": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"enum": ["DEFAULT", "MODIFIED", "CUSTOM"],
|
|
31
|
+
"description": "The type of the category, indicating whether it is a default, modified, or custom category."
|
|
32
|
+
},
|
|
33
|
+
"createdAt": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"format": "date-time",
|
|
36
|
+
"description": "The date and time when the category was created, in ISO 8601 format."
|
|
37
|
+
},
|
|
38
|
+
"updatedAt": {
|
|
39
|
+
"type": ["string", "null"],
|
|
40
|
+
"format": "date-time",
|
|
41
|
+
"description": "The date and time when the category was last updated, in ISO 8601 format. Can be null if the category has never been updated."
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"required": [
|
|
45
|
+
"id",
|
|
46
|
+
"name",
|
|
47
|
+
"description",
|
|
48
|
+
"parentId",
|
|
49
|
+
"defaultCategoryId",
|
|
50
|
+
"categoryType",
|
|
51
|
+
"createdAt",
|
|
52
|
+
"updatedAt"
|
|
53
|
+
],
|
|
54
|
+
"additionalProperties": false,
|
|
55
|
+
"if": {
|
|
56
|
+
"properties": {
|
|
57
|
+
"categoryType": {
|
|
58
|
+
"const": "MODIFIED"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"then": {
|
|
63
|
+
"required": ["defaultCategoryId"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"title": "ID",
|
|
12
|
+
"description": "A unique identifier for the entity."
|
|
13
|
+
},
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"title": "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": "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": "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
|
+
"createdAt": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"title": "Created At",
|
|
46
|
+
"format": "date-time",
|
|
47
|
+
"description": "The date and time when the entity was created, in ISO 8601 format."
|
|
48
|
+
},
|
|
49
|
+
"updatedAt": {
|
|
50
|
+
"type": ["string", "null"],
|
|
51
|
+
"title": "Updated At",
|
|
52
|
+
"format": "date-time",
|
|
53
|
+
"description": "The date and time when the entity was last updated, in ISO 8601 format. This can be null if the entity has not been updated since creation."
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": [
|
|
57
|
+
"id",
|
|
58
|
+
"name",
|
|
59
|
+
"description",
|
|
60
|
+
"entityType",
|
|
61
|
+
"entityStatus",
|
|
62
|
+
"createdAt",
|
|
63
|
+
"updatedAt"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _category = _interopRequireDefault(require("./category.json"));
|
|
8
|
+
var _entity = _interopRequireDefault(require("./entity.json"));
|
|
9
|
+
var _lucaSchema = _interopRequireDefault(require("./lucaSchema.json"));
|
|
10
|
+
var _recurringTransaction = _interopRequireDefault(require("./recurringTransaction.json"));
|
|
11
|
+
var _recurringTransactionEvent = _interopRequireDefault(require("./recurringTransactionEvent.json"));
|
|
12
|
+
var _schema = _interopRequireDefault(require("./schema.json"));
|
|
13
|
+
var _transaction = _interopRequireDefault(require("./transaction.json"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
var schemas = {
|
|
16
|
+
category: _category["default"],
|
|
17
|
+
entity: _entity["default"],
|
|
18
|
+
lucaSchema: _lucaSchema["default"],
|
|
19
|
+
recurringTransaction: _recurringTransaction["default"],
|
|
20
|
+
recurringTransactionEvent: _recurringTransactionEvent["default"],
|
|
21
|
+
schema: _schema["default"],
|
|
22
|
+
transaction: _transaction["default"]
|
|
23
|
+
};
|
|
24
|
+
var _default = exports["default"] = schemas;
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_category","_interopRequireDefault","require","_entity","_lucaSchema","_recurringTransaction","_recurringTransactionEvent","_schema","_transaction","obj","__esModule","schemas","category","entity","lucaSchema","recurringTransaction","recurringTransactionEvent","schema","transaction","_default","exports"],"sources":["../../../src/schemas/index.js"],"sourcesContent":["import category from './category.json';\nimport entity from './entity.json';\nimport lucaSchema from './lucaSchema.json';\nimport recurringTransaction from './recurringTransaction.json';\nimport recurringTransactionEvent from './recurringTransactionEvent.json';\nimport schema from './schema.json';\nimport transaction from './transaction.json';\n\nconst schemas = {\n category,\n entity,\n lucaSchema,\n recurringTransaction,\n recurringTransactionEvent,\n schema,\n transaction\n};\n\nexport default schemas;\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,qBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,0BAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AAA6C,SAAAD,uBAAAQ,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE7C,IAAME,OAAO,GAAG;EACdC,QAAQ,EAARA,oBAAQ;EACRC,MAAM,EAANA,kBAAM;EACNC,UAAU,EAAVA,sBAAU;EACVC,oBAAoB,EAApBA,gCAAoB;EACpBC,yBAAyB,EAAzBA,qCAAyB;EACzBC,MAAM,EAANA,kBAAM;EACNC,WAAW,EAAXA;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEaT,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/luca-schema.json",
|
|
4
|
+
"title": "Luca Schema",
|
|
5
|
+
"description": "Schema for the luca ledger",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema": {
|
|
9
|
+
"$ref": "./schema.json"
|
|
10
|
+
},
|
|
11
|
+
"categories": {
|
|
12
|
+
"type": "array",
|
|
13
|
+
"description": "List of categories",
|
|
14
|
+
"uniqueItems": true,
|
|
15
|
+
"items": {
|
|
16
|
+
"$ref": "./category.json"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"entities": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"description": "List of entities",
|
|
22
|
+
"uniqueItems": true,
|
|
23
|
+
"items": {
|
|
24
|
+
"$ref": "./entity.json"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"recurringTransactions": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"description": "List of recurring transactions",
|
|
30
|
+
"uniqueItems": true,
|
|
31
|
+
"items": {
|
|
32
|
+
"$ref": "./recurringTransaction.json"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"recurringTransactionEvents": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"description": "List of recurring transaction events",
|
|
38
|
+
"uniqueItems": true,
|
|
39
|
+
"items": {
|
|
40
|
+
"$ref": "./recurringTransactionEvent.json"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"transactions": {
|
|
44
|
+
"type": "array",
|
|
45
|
+
"description": "List of transactions",
|
|
46
|
+
"uniqueItems": true,
|
|
47
|
+
"items": {
|
|
48
|
+
"$ref": "./transaction.json"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"required": ["schema", "entities", "transactions"],
|
|
53
|
+
"additionalProperties": false
|
|
54
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Unique identifier for the transaction."
|
|
11
|
+
},
|
|
12
|
+
"payorId": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Identifier for the payor in the transaction."
|
|
15
|
+
},
|
|
16
|
+
"payeeId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Identifier for the payee in the transaction."
|
|
19
|
+
},
|
|
20
|
+
"categoryId": {
|
|
21
|
+
"type": ["string", "null"],
|
|
22
|
+
"description": "Category identifier for organizing the transaction. Can be null if not categorized."
|
|
23
|
+
},
|
|
24
|
+
"amount": {
|
|
25
|
+
"type": "number",
|
|
26
|
+
"description": "The monetary value of the transaction."
|
|
27
|
+
},
|
|
28
|
+
"frequency": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"enum": ["DAY", "WEEK", "MONTH", "YEAR"],
|
|
31
|
+
"description": "Defines the base unit of time for the repetition."
|
|
32
|
+
},
|
|
33
|
+
"interval": {
|
|
34
|
+
"type": "integer",
|
|
35
|
+
"minimum": 1,
|
|
36
|
+
"description": "Specifies the number of frequency units between each occurrence (e.g., every 2 weeks)."
|
|
37
|
+
},
|
|
38
|
+
"occurrences": {
|
|
39
|
+
"type": ["integer", "null"],
|
|
40
|
+
"minimum": 1,
|
|
41
|
+
"description": "The total number of times the transaction should occur. Can be null if not specified."
|
|
42
|
+
},
|
|
43
|
+
"startOn": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"format": "date",
|
|
46
|
+
"description": "The date on which the recurring transaction series should begin."
|
|
47
|
+
},
|
|
48
|
+
"endOn": {
|
|
49
|
+
"type": ["string", "null"],
|
|
50
|
+
"format": "date",
|
|
51
|
+
"description": "The date on which the recurring transaction series should end. Can be null."
|
|
52
|
+
},
|
|
53
|
+
"description": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "A detailed description of the transaction."
|
|
56
|
+
},
|
|
57
|
+
"recurringTransactionState": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"enum": ["ACTIVE", "PAUSED", "COMPLETED", "CANCELLED"],
|
|
60
|
+
"description": "Current state of the recurring transaction series."
|
|
61
|
+
},
|
|
62
|
+
"createdAt": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"format": "date-time",
|
|
65
|
+
"description": "Timestamp of when the transaction was created."
|
|
66
|
+
},
|
|
67
|
+
"updatedAt": {
|
|
68
|
+
"type": ["string", "null"],
|
|
69
|
+
"format": "date-time",
|
|
70
|
+
"description": "Timestamp of the last update to the transaction. Can be null if not updated."
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"required": [
|
|
74
|
+
"id",
|
|
75
|
+
"payorId",
|
|
76
|
+
"payeeId",
|
|
77
|
+
"categoryId",
|
|
78
|
+
"amount",
|
|
79
|
+
"frequency",
|
|
80
|
+
"interval",
|
|
81
|
+
"occurrences",
|
|
82
|
+
"startOn",
|
|
83
|
+
"endOn",
|
|
84
|
+
"description",
|
|
85
|
+
"recurringTransactionState",
|
|
86
|
+
"createdAt",
|
|
87
|
+
"updatedAt"
|
|
88
|
+
],
|
|
89
|
+
"additionalProperties": false
|
|
90
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Unique identifier for the occurrence record."
|
|
11
|
+
},
|
|
12
|
+
"transactionId": {
|
|
13
|
+
"type": ["string", "null"],
|
|
14
|
+
"description": "Identifier of the actual transaction, required if the occurrence is modified."
|
|
15
|
+
},
|
|
16
|
+
"recurringTransactionId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Identifier of the associated recurring transaction."
|
|
19
|
+
},
|
|
20
|
+
"expectedDate": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"format": "date",
|
|
23
|
+
"description": "The date when the occurrence is expected."
|
|
24
|
+
},
|
|
25
|
+
"status": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["MODIFIED", "DELETED"],
|
|
28
|
+
"description": "Status of the occurrence, indicating if it has been modified or logically deleted."
|
|
29
|
+
},
|
|
30
|
+
"createdAt": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"format": "date-time",
|
|
33
|
+
"description": "Timestamp of when the occurrence was created."
|
|
34
|
+
},
|
|
35
|
+
"updatedAt": {
|
|
36
|
+
"type": ["string", "null"],
|
|
37
|
+
"format": "date-time",
|
|
38
|
+
"description": "Timestamp of the last update to the occurrence. Nullable to accommodate occurrences that have not been updated."
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"required": [
|
|
42
|
+
"id",
|
|
43
|
+
"transactionId",
|
|
44
|
+
"recurringTransactionId",
|
|
45
|
+
"expectedDate",
|
|
46
|
+
"status",
|
|
47
|
+
"createdAt",
|
|
48
|
+
"updatedAt"
|
|
49
|
+
],
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"if": {
|
|
52
|
+
"properties": { "status": { "const": "modified" } }
|
|
53
|
+
},
|
|
54
|
+
"then": {
|
|
55
|
+
"required": ["transactionId"]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/schema.json",
|
|
4
|
+
"title": "Schema",
|
|
5
|
+
"description": "Schema object for the Luca Schema",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"description": "The id of the schema",
|
|
10
|
+
"type": "string",
|
|
11
|
+
"const": "luca-schema"
|
|
12
|
+
},
|
|
13
|
+
"name": {
|
|
14
|
+
"description": "The name of the schema",
|
|
15
|
+
"type": "string",
|
|
16
|
+
"const": "Luca Schema"
|
|
17
|
+
},
|
|
18
|
+
"version": {
|
|
19
|
+
"description": "The version of the schema",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
"properties": {
|
|
7
|
+
"id": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "A unique identifier for the transaction."
|
|
10
|
+
},
|
|
11
|
+
"payorId": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The identifier for the entity making the payment."
|
|
14
|
+
},
|
|
15
|
+
"payeeId": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "The identifier for the entity receiving the payment."
|
|
18
|
+
},
|
|
19
|
+
"categoryId": {
|
|
20
|
+
"type": ["string", "null"],
|
|
21
|
+
"description": "The identifier for the category this transaction is associated with. Can be null if not categorized."
|
|
22
|
+
},
|
|
23
|
+
"amount": {
|
|
24
|
+
"type": "number",
|
|
25
|
+
"description": "The monetary value of the transaction."
|
|
26
|
+
},
|
|
27
|
+
"date": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "date",
|
|
30
|
+
"description": "The date the transaction took place."
|
|
31
|
+
},
|
|
32
|
+
"description": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "A textual description of the transaction."
|
|
35
|
+
},
|
|
36
|
+
"transactionState": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"enum": [
|
|
39
|
+
"PLANNED",
|
|
40
|
+
"SCHEDULED",
|
|
41
|
+
"PENDING",
|
|
42
|
+
"COMPLETED",
|
|
43
|
+
"CANCELLED",
|
|
44
|
+
"FAILED",
|
|
45
|
+
"DISPUTED",
|
|
46
|
+
"REFUNDED",
|
|
47
|
+
"TENTATIVE",
|
|
48
|
+
"UPCOMING",
|
|
49
|
+
"DELETED"
|
|
50
|
+
],
|
|
51
|
+
"description": "The current state of the transaction."
|
|
52
|
+
},
|
|
53
|
+
"createdAt": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"format": "date-time",
|
|
56
|
+
"description": "The timestamp when the transaction was created."
|
|
57
|
+
},
|
|
58
|
+
"updatedAt": {
|
|
59
|
+
"type": ["string", "null"],
|
|
60
|
+
"format": "date-time",
|
|
61
|
+
"description": "The timestamp when the transaction was last updated. Nullable to accommodate transactions that have not been updated."
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": [
|
|
65
|
+
"id",
|
|
66
|
+
"payorId",
|
|
67
|
+
"payeeId",
|
|
68
|
+
"categoryId",
|
|
69
|
+
"amount",
|
|
70
|
+
"date",
|
|
71
|
+
"description",
|
|
72
|
+
"transactionState",
|
|
73
|
+
"createdAt",
|
|
74
|
+
"updatedAt"
|
|
75
|
+
],
|
|
76
|
+
"additionalProperties": false
|
|
77
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _ = _interopRequireDefault(require("ajv/dist/2020"));
|
|
8
|
+
var _ajvFormats = _interopRequireDefault(require("ajv-formats"));
|
|
9
|
+
var _schemas = _interopRequireDefault(require("./schemas"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
var ajv = new _["default"]();
|
|
18
|
+
(0, _ajvFormats["default"])(ajv);
|
|
19
|
+
Object.entries(_schemas["default"]).forEach(function (_ref) {
|
|
20
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
21
|
+
key = _ref2[0],
|
|
22
|
+
schema = _ref2[1];
|
|
23
|
+
if (!ajv.validateSchema(schema)) {
|
|
24
|
+
console.error("Invalid schema: ".concat(key));
|
|
25
|
+
console.error(ajv.errors);
|
|
26
|
+
} else {
|
|
27
|
+
ajv.addSchema(schema, key);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var validators = {
|
|
31
|
+
validateCategory: ajv.getSchema('category'),
|
|
32
|
+
validateEntity: ajv.getSchema('entity'),
|
|
33
|
+
validateLucaSchema: ajv.getSchema('lucaSchema'),
|
|
34
|
+
validateRecurringTransaction: ajv.getSchema('recurringTransaction'),
|
|
35
|
+
validateRecurringTransactionEvent: ajv.getSchema('recurringTransactionEvent'),
|
|
36
|
+
validateSchema: ajv.getSchema('schema'),
|
|
37
|
+
validateTransaction: ajv.getSchema('transaction')
|
|
38
|
+
};
|
|
39
|
+
var _default = exports["default"] = validators;
|
|
40
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "A unique identifier for the category."
|
|
11
|
+
},
|
|
12
|
+
"name": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The name of the category."
|
|
15
|
+
},
|
|
16
|
+
"description": {
|
|
17
|
+
"type": ["string", "null"],
|
|
18
|
+
"description": "A description of the category, providing additional context. Can be null if not specified."
|
|
19
|
+
},
|
|
20
|
+
"parentId": {
|
|
21
|
+
"type": ["string", "null"],
|
|
22
|
+
"description": "The identifier of the parent category, if any. Null if the category is top-level."
|
|
23
|
+
},
|
|
24
|
+
"defaultCategoryId": {
|
|
25
|
+
"type": ["string", "null"],
|
|
26
|
+
"description": "For custom categories, this indicates the default category from which this was derived. Required if categoryType is CUSTOM."
|
|
27
|
+
},
|
|
28
|
+
"categoryType": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"enum": ["DEFAULT", "MODIFIED", "CUSTOM"],
|
|
31
|
+
"description": "The type of the category, indicating whether it is a default, modified, or custom category."
|
|
32
|
+
},
|
|
33
|
+
"createdAt": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"format": "date-time",
|
|
36
|
+
"description": "The date and time when the category was created, in ISO 8601 format."
|
|
37
|
+
},
|
|
38
|
+
"updatedAt": {
|
|
39
|
+
"type": ["string", "null"],
|
|
40
|
+
"format": "date-time",
|
|
41
|
+
"description": "The date and time when the category was last updated, in ISO 8601 format. Can be null if the category has never been updated."
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"required": [
|
|
45
|
+
"id",
|
|
46
|
+
"name",
|
|
47
|
+
"description",
|
|
48
|
+
"parentId",
|
|
49
|
+
"defaultCategoryId",
|
|
50
|
+
"categoryType",
|
|
51
|
+
"createdAt",
|
|
52
|
+
"updatedAt"
|
|
53
|
+
],
|
|
54
|
+
"additionalProperties": false,
|
|
55
|
+
"if": {
|
|
56
|
+
"properties": {
|
|
57
|
+
"categoryType": {
|
|
58
|
+
"const": "MODIFIED"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"then": {
|
|
63
|
+
"required": ["defaultCategoryId"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"title": "ID",
|
|
12
|
+
"description": "A unique identifier for the entity."
|
|
13
|
+
},
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"title": "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": "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": "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
|
+
"createdAt": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"title": "Created At",
|
|
46
|
+
"format": "date-time",
|
|
47
|
+
"description": "The date and time when the entity was created, in ISO 8601 format."
|
|
48
|
+
},
|
|
49
|
+
"updatedAt": {
|
|
50
|
+
"type": ["string", "null"],
|
|
51
|
+
"title": "Updated At",
|
|
52
|
+
"format": "date-time",
|
|
53
|
+
"description": "The date and time when the entity was last updated, in ISO 8601 format. This can be null if the entity has not been updated since creation."
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": [
|
|
57
|
+
"id",
|
|
58
|
+
"name",
|
|
59
|
+
"description",
|
|
60
|
+
"entityType",
|
|
61
|
+
"entityStatus",
|
|
62
|
+
"createdAt",
|
|
63
|
+
"updatedAt"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import category from './category.json';
|
|
2
|
+
import entity from './entity.json';
|
|
3
|
+
import lucaSchema from './lucaSchema.json';
|
|
4
|
+
import recurringTransaction from './recurringTransaction.json';
|
|
5
|
+
import recurringTransactionEvent from './recurringTransactionEvent.json';
|
|
6
|
+
import schema from './schema.json';
|
|
7
|
+
import transaction from './transaction.json';
|
|
8
|
+
|
|
9
|
+
const schemas = {
|
|
10
|
+
category,
|
|
11
|
+
entity,
|
|
12
|
+
lucaSchema,
|
|
13
|
+
recurringTransaction,
|
|
14
|
+
recurringTransactionEvent,
|
|
15
|
+
schema,
|
|
16
|
+
transaction
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default schemas;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/luca-schema.json",
|
|
4
|
+
"title": "Luca Schema",
|
|
5
|
+
"description": "Schema for the luca ledger",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema": {
|
|
9
|
+
"$ref": "./schema.json"
|
|
10
|
+
},
|
|
11
|
+
"categories": {
|
|
12
|
+
"type": "array",
|
|
13
|
+
"description": "List of categories",
|
|
14
|
+
"uniqueItems": true,
|
|
15
|
+
"items": {
|
|
16
|
+
"$ref": "./category.json"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"entities": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"description": "List of entities",
|
|
22
|
+
"uniqueItems": true,
|
|
23
|
+
"items": {
|
|
24
|
+
"$ref": "./entity.json"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"recurringTransactions": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"description": "List of recurring transactions",
|
|
30
|
+
"uniqueItems": true,
|
|
31
|
+
"items": {
|
|
32
|
+
"$ref": "./recurringTransaction.json"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"recurringTransactionEvents": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"description": "List of recurring transaction events",
|
|
38
|
+
"uniqueItems": true,
|
|
39
|
+
"items": {
|
|
40
|
+
"$ref": "./recurringTransactionEvent.json"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"transactions": {
|
|
44
|
+
"type": "array",
|
|
45
|
+
"description": "List of transactions",
|
|
46
|
+
"uniqueItems": true,
|
|
47
|
+
"items": {
|
|
48
|
+
"$ref": "./transaction.json"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"required": ["schema", "entities", "transactions"],
|
|
53
|
+
"additionalProperties": false
|
|
54
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Unique identifier for the transaction."
|
|
11
|
+
},
|
|
12
|
+
"payorId": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Identifier for the payor in the transaction."
|
|
15
|
+
},
|
|
16
|
+
"payeeId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Identifier for the payee in the transaction."
|
|
19
|
+
},
|
|
20
|
+
"categoryId": {
|
|
21
|
+
"type": ["string", "null"],
|
|
22
|
+
"description": "Category identifier for organizing the transaction. Can be null if not categorized."
|
|
23
|
+
},
|
|
24
|
+
"amount": {
|
|
25
|
+
"type": "number",
|
|
26
|
+
"description": "The monetary value of the transaction."
|
|
27
|
+
},
|
|
28
|
+
"frequency": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"enum": ["DAY", "WEEK", "MONTH", "YEAR"],
|
|
31
|
+
"description": "Defines the base unit of time for the repetition."
|
|
32
|
+
},
|
|
33
|
+
"interval": {
|
|
34
|
+
"type": "integer",
|
|
35
|
+
"minimum": 1,
|
|
36
|
+
"description": "Specifies the number of frequency units between each occurrence (e.g., every 2 weeks)."
|
|
37
|
+
},
|
|
38
|
+
"occurrences": {
|
|
39
|
+
"type": ["integer", "null"],
|
|
40
|
+
"minimum": 1,
|
|
41
|
+
"description": "The total number of times the transaction should occur. Can be null if not specified."
|
|
42
|
+
},
|
|
43
|
+
"startOn": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"format": "date",
|
|
46
|
+
"description": "The date on which the recurring transaction series should begin."
|
|
47
|
+
},
|
|
48
|
+
"endOn": {
|
|
49
|
+
"type": ["string", "null"],
|
|
50
|
+
"format": "date",
|
|
51
|
+
"description": "The date on which the recurring transaction series should end. Can be null."
|
|
52
|
+
},
|
|
53
|
+
"description": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "A detailed description of the transaction."
|
|
56
|
+
},
|
|
57
|
+
"recurringTransactionState": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"enum": ["ACTIVE", "PAUSED", "COMPLETED", "CANCELLED"],
|
|
60
|
+
"description": "Current state of the recurring transaction series."
|
|
61
|
+
},
|
|
62
|
+
"createdAt": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"format": "date-time",
|
|
65
|
+
"description": "Timestamp of when the transaction was created."
|
|
66
|
+
},
|
|
67
|
+
"updatedAt": {
|
|
68
|
+
"type": ["string", "null"],
|
|
69
|
+
"format": "date-time",
|
|
70
|
+
"description": "Timestamp of the last update to the transaction. Can be null if not updated."
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"required": [
|
|
74
|
+
"id",
|
|
75
|
+
"payorId",
|
|
76
|
+
"payeeId",
|
|
77
|
+
"categoryId",
|
|
78
|
+
"amount",
|
|
79
|
+
"frequency",
|
|
80
|
+
"interval",
|
|
81
|
+
"occurrences",
|
|
82
|
+
"startOn",
|
|
83
|
+
"endOn",
|
|
84
|
+
"description",
|
|
85
|
+
"recurringTransactionState",
|
|
86
|
+
"createdAt",
|
|
87
|
+
"updatedAt"
|
|
88
|
+
],
|
|
89
|
+
"additionalProperties": false
|
|
90
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Unique identifier for the occurrence record."
|
|
11
|
+
},
|
|
12
|
+
"transactionId": {
|
|
13
|
+
"type": ["string", "null"],
|
|
14
|
+
"description": "Identifier of the actual transaction, required if the occurrence is modified."
|
|
15
|
+
},
|
|
16
|
+
"recurringTransactionId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Identifier of the associated recurring transaction."
|
|
19
|
+
},
|
|
20
|
+
"expectedDate": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"format": "date",
|
|
23
|
+
"description": "The date when the occurrence is expected."
|
|
24
|
+
},
|
|
25
|
+
"status": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["MODIFIED", "DELETED"],
|
|
28
|
+
"description": "Status of the occurrence, indicating if it has been modified or logically deleted."
|
|
29
|
+
},
|
|
30
|
+
"createdAt": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"format": "date-time",
|
|
33
|
+
"description": "Timestamp of when the occurrence was created."
|
|
34
|
+
},
|
|
35
|
+
"updatedAt": {
|
|
36
|
+
"type": ["string", "null"],
|
|
37
|
+
"format": "date-time",
|
|
38
|
+
"description": "Timestamp of the last update to the occurrence. Nullable to accommodate occurrences that have not been updated."
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"required": [
|
|
42
|
+
"id",
|
|
43
|
+
"transactionId",
|
|
44
|
+
"recurringTransactionId",
|
|
45
|
+
"expectedDate",
|
|
46
|
+
"status",
|
|
47
|
+
"createdAt",
|
|
48
|
+
"updatedAt"
|
|
49
|
+
],
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"if": {
|
|
52
|
+
"properties": { "status": { "const": "modified" } }
|
|
53
|
+
},
|
|
54
|
+
"then": {
|
|
55
|
+
"required": ["transactionId"]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/LucaFinancial/LucaSchema/main/src/schemas/schema.json",
|
|
4
|
+
"title": "Schema",
|
|
5
|
+
"description": "Schema object for the Luca Schema",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"description": "The id of the schema",
|
|
10
|
+
"type": "string",
|
|
11
|
+
"const": "luca-schema"
|
|
12
|
+
},
|
|
13
|
+
"name": {
|
|
14
|
+
"description": "The name of the schema",
|
|
15
|
+
"type": "string",
|
|
16
|
+
"const": "Luca Schema"
|
|
17
|
+
},
|
|
18
|
+
"version": {
|
|
19
|
+
"description": "The version of the schema",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
"properties": {
|
|
7
|
+
"id": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "A unique identifier for the transaction."
|
|
10
|
+
},
|
|
11
|
+
"payorId": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The identifier for the entity making the payment."
|
|
14
|
+
},
|
|
15
|
+
"payeeId": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "The identifier for the entity receiving the payment."
|
|
18
|
+
},
|
|
19
|
+
"categoryId": {
|
|
20
|
+
"type": ["string", "null"],
|
|
21
|
+
"description": "The identifier for the category this transaction is associated with. Can be null if not categorized."
|
|
22
|
+
},
|
|
23
|
+
"amount": {
|
|
24
|
+
"type": "number",
|
|
25
|
+
"description": "The monetary value of the transaction."
|
|
26
|
+
},
|
|
27
|
+
"date": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "date",
|
|
30
|
+
"description": "The date the transaction took place."
|
|
31
|
+
},
|
|
32
|
+
"description": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "A textual description of the transaction."
|
|
35
|
+
},
|
|
36
|
+
"transactionState": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"enum": [
|
|
39
|
+
"PLANNED",
|
|
40
|
+
"SCHEDULED",
|
|
41
|
+
"PENDING",
|
|
42
|
+
"COMPLETED",
|
|
43
|
+
"CANCELLED",
|
|
44
|
+
"FAILED",
|
|
45
|
+
"DISPUTED",
|
|
46
|
+
"REFUNDED",
|
|
47
|
+
"TENTATIVE",
|
|
48
|
+
"UPCOMING",
|
|
49
|
+
"DELETED"
|
|
50
|
+
],
|
|
51
|
+
"description": "The current state of the transaction."
|
|
52
|
+
},
|
|
53
|
+
"createdAt": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"format": "date-time",
|
|
56
|
+
"description": "The timestamp when the transaction was created."
|
|
57
|
+
},
|
|
58
|
+
"updatedAt": {
|
|
59
|
+
"type": ["string", "null"],
|
|
60
|
+
"format": "date-time",
|
|
61
|
+
"description": "The timestamp when the transaction was last updated. Nullable to accommodate transactions that have not been updated."
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": [
|
|
65
|
+
"id",
|
|
66
|
+
"payorId",
|
|
67
|
+
"payeeId",
|
|
68
|
+
"categoryId",
|
|
69
|
+
"amount",
|
|
70
|
+
"date",
|
|
71
|
+
"description",
|
|
72
|
+
"transactionState",
|
|
73
|
+
"createdAt",
|
|
74
|
+
"updatedAt"
|
|
75
|
+
],
|
|
76
|
+
"additionalProperties": false
|
|
77
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Ajv2020 from 'ajv/dist/2020';
|
|
2
|
+
import addFormats from 'ajv-formats';
|
|
3
|
+
|
|
4
|
+
import schemas from './schemas';
|
|
5
|
+
|
|
6
|
+
const ajv = new Ajv2020();
|
|
7
|
+
addFormats(ajv);
|
|
8
|
+
|
|
9
|
+
Object.entries(schemas).forEach(([key, schema]) => {
|
|
10
|
+
if (!ajv.validateSchema(schema)) {
|
|
11
|
+
console.error(`Invalid schema: ${key}`);
|
|
12
|
+
console.error(ajv.errors);
|
|
13
|
+
} else {
|
|
14
|
+
ajv.addSchema(schema, key);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const validators = {
|
|
19
|
+
validateCategory: ajv.getSchema('category'),
|
|
20
|
+
validateEntity: ajv.getSchema('entity'),
|
|
21
|
+
validateLucaSchema: ajv.getSchema('lucaSchema'),
|
|
22
|
+
validateRecurringTransaction: ajv.getSchema('recurringTransaction'),
|
|
23
|
+
validateRecurringTransactionEvent: ajv.getSchema('recurringTransactionEvent'),
|
|
24
|
+
validateSchema: ajv.getSchema('schema'),
|
|
25
|
+
validateTransaction: ajv.getSchema('transaction')
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default validators;
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luca-financial/luca-schema",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Schemas for the Luca Ledger application",
|
|
5
|
+
"author": "Johnathan Aspinwall",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"homepage": "https://lucaledger.app",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/LucaFinancial/LucaSchema"
|
|
13
|
+
},
|
|
14
|
+
"jest": {
|
|
15
|
+
"transform": {
|
|
16
|
+
"^.+\\.[t|j]sx?$": "babel-jest"
|
|
17
|
+
},
|
|
18
|
+
"testMatch": [
|
|
19
|
+
"**/dist/cjs/tests/**/*.test.js"
|
|
20
|
+
],
|
|
21
|
+
"moduleFileExtensions": [
|
|
22
|
+
"js",
|
|
23
|
+
"json",
|
|
24
|
+
"node"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "yarn && yarn clean && node scripts/build.cjs && babel src --out-dir dist/cjs --source-maps",
|
|
29
|
+
"clean": "node scripts/clean.cjs",
|
|
30
|
+
"lint": "prettier --check . && eslint .",
|
|
31
|
+
"publish-beta": "yarn && yarn build && yarn publish --tag beta --access public",
|
|
32
|
+
"test": "yarn build && jest"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@babel/cli": "^7.24.1",
|
|
36
|
+
"@babel/core": "^7.24.4",
|
|
37
|
+
"@babel/preset-env": "^7.24.4",
|
|
38
|
+
"ajv": "^8.12.0",
|
|
39
|
+
"ajv-formats": "^2.1.1",
|
|
40
|
+
"babel-jest": "^29.7.0",
|
|
41
|
+
"fs-extra": "^11.2.0",
|
|
42
|
+
"jest": "^29.7.0",
|
|
43
|
+
"prettier": "^3.2.5",
|
|
44
|
+
"rimraf": "^5.0.5"
|
|
45
|
+
},
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"import": "./dist/esm/index.js",
|
|
49
|
+
"require": "./dist/cjs/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./schemas": {
|
|
52
|
+
"import": "./dist/esm/schemas/*.json",
|
|
53
|
+
"require": "./dist/cjs/schemas/*.json"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"dist/cjs/index.js",
|
|
58
|
+
"dist/cjs/validators.js",
|
|
59
|
+
"dist/cjs/schemas/",
|
|
60
|
+
"dist/esm/index.js",
|
|
61
|
+
"dist/esm/validators.js",
|
|
62
|
+
"dist/esm/schemas/",
|
|
63
|
+
"LICENSE",
|
|
64
|
+
"README.md"
|
|
65
|
+
]
|
|
66
|
+
}
|