bkper 2.7.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +8 -8
  2. package/bun.lockb +0 -0
  3. package/package.json +9 -32
  4. package/src/auth/keys.json +12 -0
  5. package/src/auth/local-auth-service.ts +73 -0
  6. package/src/cli.ts +57 -0
  7. package/tsconfig.json +25 -0
  8. package/lib/auth/keys.json +0 -12
  9. package/lib/auth/local-auth-service.js +0 -80
  10. package/lib/cli.js +0 -64
  11. package/lib/index.d.ts +0 -1775
  12. package/lib/index.js +0 -42
  13. package/lib/model/Account.js +0 -381
  14. package/lib/model/Amount.js +0 -295
  15. package/lib/model/App.js +0 -95
  16. package/lib/model/Bkper.js +0 -101
  17. package/lib/model/Book.js +0 -713
  18. package/lib/model/Collection.js +0 -43
  19. package/lib/model/Config.js +0 -3
  20. package/lib/model/Connection.js +0 -257
  21. package/lib/model/Enums.js +0 -138
  22. package/lib/model/File.js +0 -124
  23. package/lib/model/Group.js +0 -244
  24. package/lib/model/Integration.js +0 -112
  25. package/lib/model/Transaction.js +0 -715
  26. package/lib/model/TransactionIterator.js +0 -154
  27. package/lib/model/TransactionPage.js +0 -93
  28. package/lib/model/User.js +0 -93
  29. package/lib/service/account-service.js +0 -43
  30. package/lib/service/app-service.js +0 -35
  31. package/lib/service/balances-service.js +0 -21
  32. package/lib/service/book-service.js +0 -37
  33. package/lib/service/connection-service.js +0 -72
  34. package/lib/service/file-service.js +0 -28
  35. package/lib/service/group-service.js +0 -72
  36. package/lib/service/http-api-request.js +0 -169
  37. package/lib/service/integration-service.js +0 -53
  38. package/lib/service/transaction-service.js +0 -115
  39. package/lib/service/user-service.js +0 -21
  40. package/lib/tsdoc-metadata.json +0 -11
  41. package/lib/utils.js +0 -341
@@ -1,244 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.Group = void 0;
32
- const GroupService = __importStar(require("../service/group-service"));
33
- const utils_1 = require("../utils");
34
- const Account_1 = require("./Account");
35
- const Utils = __importStar(require("../utils"));
36
- /**
37
- * This class defines a Group of [[Accounts]].
38
- *
39
- * Accounts can be grouped by different meaning, like Expenses, Revenue, Assets, Liabilities and so on
40
- *
41
- * Its useful to keep organized and for high level analysis.
42
- *
43
- * @public
44
- */
45
- class Group {
46
- /**
47
- *
48
- * @returns The wrapped plain json object
49
- */
50
- json() {
51
- return this.wrapped;
52
- }
53
- /**
54
- * @returns The id of this Group
55
- */
56
- getId() {
57
- return this.wrapped.id;
58
- }
59
- /**
60
- * @returns The parent Group
61
- */
62
- getParent() {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- if (this.wrapped.parent) {
65
- return yield this.book.getGroup(this.wrapped.parent.id);
66
- }
67
- else {
68
- return null;
69
- }
70
- });
71
- }
72
- /**
73
- * Sets the parent Group.
74
- *
75
- * @returns This Group, for chainning.
76
- */
77
- setParent(group) {
78
- if (group) {
79
- this.wrapped.parent = { id: group.getId(), name: group.getName(), normalizedName: group.getNormalizedName() };
80
- }
81
- else {
82
- this.wrapped.parent = null;
83
- }
84
- return this;
85
- }
86
- /**
87
- * @returns The name of this Group
88
- */
89
- getName() {
90
- return this.wrapped.name;
91
- }
92
- /**
93
- * Sets the name of the Group.
94
- *
95
- * @returns This Group, for chainning.
96
- */
97
- setName(name) {
98
- this.wrapped.name = name;
99
- return this;
100
- }
101
- /**
102
- * @returns The name of this group without spaces and special characters
103
- */
104
- getNormalizedName() {
105
- if (this.wrapped.normalizedName) {
106
- return this.wrapped.normalizedName;
107
- }
108
- else {
109
- return utils_1.normalizeText(this.getName());
110
- }
111
- }
112
- /**
113
- * @returns All Accounts of this group.
114
- */
115
- getAccounts() {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- let accountsPlain = yield GroupService.getAccounts(this.book.getId(), this.getId());
118
- if (!accountsPlain) {
119
- return [];
120
- }
121
- let accounts = Utils.wrapObjects(new Account_1.Account(), accountsPlain);
122
- for (const account of accounts) {
123
- account.book = this.book;
124
- }
125
- return accounts;
126
- });
127
- }
128
- /**
129
- * @returns True if this group has any account in it
130
- */
131
- hasAccounts() {
132
- return this.wrapped.hasAccounts;
133
- }
134
- /**
135
- * @returns The type for of the accounts of this group. Null if mixed
136
- */
137
- getType() {
138
- return this.wrapped.type;
139
- }
140
- /**
141
- * Gets the custom properties stored in this Group
142
- */
143
- getProperties() {
144
- return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
145
- }
146
- /**
147
- * Sets the custom properties of the Group
148
- *
149
- * @param properties - Object with key/value pair properties
150
- *
151
- * @returns This Group, for chainning.
152
- */
153
- setProperties(properties) {
154
- this.wrapped.properties = Object.assign({}, properties);
155
- return this;
156
- }
157
- /**
158
- * Gets the property value for given keys. First property found will be retrieved
159
- *
160
- * @param keys - The property key
161
- */
162
- getProperty(...keys) {
163
- for (let index = 0; index < keys.length; index++) {
164
- const key = keys[index];
165
- let value = this.wrapped.properties != null ? this.wrapped.properties[key] : null;
166
- if (value != null && value.trim() != '') {
167
- return value;
168
- }
169
- }
170
- return null;
171
- }
172
- /**
173
- * Sets a custom property in the Group.
174
- *
175
- * @param key - The property key
176
- * @param value - The property value
177
- */
178
- setProperty(key, value) {
179
- if (key == null || key.trim() == '') {
180
- return this;
181
- }
182
- if (this.wrapped.properties == null) {
183
- this.wrapped.properties = {};
184
- }
185
- this.wrapped.properties[key] = value;
186
- return this;
187
- }
188
- /**
189
- * Delete a custom property
190
- *
191
- * @param key - The property key
192
- *
193
- * @returns This Group, for chainning.
194
- */
195
- deleteProperty(key) {
196
- this.setProperty(key, null);
197
- return this;
198
- }
199
- /**
200
- * Tell if the Group is hidden on main transactions menu
201
- */
202
- isHidden() {
203
- return this.wrapped.hidden;
204
- }
205
- /**
206
- * Hide/Show group on main menu.
207
- */
208
- setHidden(hidden) {
209
- this.wrapped.hidden = hidden;
210
- return this;
211
- }
212
- /**
213
- * Perform create new group.
214
- */
215
- create() {
216
- return __awaiter(this, void 0, void 0, function* () {
217
- this.wrapped = yield GroupService.createGroup(this.book.getId(), this.wrapped);
218
- this.book.updateGroupCache(this);
219
- return this;
220
- });
221
- }
222
- /**
223
- * Perform update group, applying pending changes.
224
- */
225
- update() {
226
- return __awaiter(this, void 0, void 0, function* () {
227
- this.wrapped = yield GroupService.updateGroup(this.book.getId(), this.wrapped);
228
- this.book.updateGroupCache(this);
229
- return this;
230
- });
231
- }
232
- /**
233
- * Perform delete group.
234
- */
235
- remove() {
236
- return __awaiter(this, void 0, void 0, function* () {
237
- this.wrapped = yield GroupService.deleteGroup(this.book.getId(), this.wrapped);
238
- this.book.removeGroupCache(this);
239
- return this;
240
- });
241
- }
242
- }
243
- exports.Group = Group;
244
- //# sourceMappingURL=Group.js.map
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Integration = void 0;
4
- /**
5
- * This class defines a Integration from an [[User]] to an external service.
6
- *
7
- * @public
8
- */
9
- class Integration {
10
- constructor(json) {
11
- this.wrapped = json;
12
- }
13
- /**
14
- * Gets the wrapped plain json object of the Integration.
15
- *
16
- * @returns The Integration wrapped plain json object
17
- */
18
- json() {
19
- return this.wrapped;
20
- }
21
- /**
22
- * Gets the [[Book]] id of the Integration.
23
- *
24
- * @returns The Integration's Book id
25
- */
26
- getBookId() {
27
- return this.wrapped.bookId;
28
- }
29
- /**
30
- * Gets the id of the Integration.
31
- *
32
- * @returns This Integration's id
33
- */
34
- getId() {
35
- return this.wrapped.id;
36
- }
37
- /**
38
- * Gets the name of the Integration.
39
- *
40
- * @returns The Integration's name
41
- */
42
- getName() {
43
- return this.wrapped.name;
44
- }
45
- /**
46
- * Gets the custom properties stored in the Integration.
47
- *
48
- * @returns Object with key/value pair properties
49
- */
50
- getProperties() {
51
- return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
52
- }
53
- /**
54
- * Sets the custom properties of the Integration.
55
- *
56
- * @param properties - Object with key/value pair properties
57
- *
58
- * @returns The Integration, for chainning
59
- */
60
- setProperties(properties) {
61
- this.wrapped.properties = Object.assign({}, properties);
62
- return this;
63
- }
64
- /**
65
- * Gets the property value for given keys. First property found will be retrieved.
66
- *
67
- * @param keys - The property key
68
- *
69
- * @returns The retrieved property value
70
- */
71
- getProperty(...keys) {
72
- for (let index = 0; index < keys.length; index++) {
73
- const key = keys[index];
74
- let value = this.wrapped.properties != null ? this.wrapped.properties[key] : null;
75
- if (value != null && value.trim() != '') {
76
- return value;
77
- }
78
- }
79
- return null;
80
- }
81
- /**
82
- * Sets a custom property in the Integration.
83
- *
84
- * @param key - The property key
85
- * @param value - The property value
86
- *
87
- * @returns The Integration, for chaining
88
- */
89
- setProperty(key, value) {
90
- if (key == null || key.trim() == '') {
91
- return this;
92
- }
93
- if (this.wrapped.properties == null) {
94
- this.wrapped.properties = {};
95
- }
96
- this.wrapped.properties[key] = value;
97
- return this;
98
- }
99
- /**
100
- * Deletes a custom property stored in the Integration.
101
- *
102
- * @param key - The property key
103
- *
104
- * @returns The Integration, for chainning
105
- */
106
- deleteProperty(key) {
107
- this.setProperty(key, null);
108
- return this;
109
- }
110
- }
111
- exports.Integration = Integration;
112
- //# sourceMappingURL=Integration.js.map