bkper 2.7.2 → 3.1.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 (42) hide show
  1. package/README.md +132 -8
  2. package/bun.lockb +0 -0
  3. package/package.json +15 -34
  4. package/src/auth/keys.json +12 -0
  5. package/src/auth/local-auth-service.ts +79 -0
  6. package/src/cli.ts +53 -0
  7. package/src/index.ts +11 -0
  8. package/tsconfig.json +27 -0
  9. package/lib/auth/keys.json +0 -12
  10. package/lib/auth/local-auth-service.js +0 -80
  11. package/lib/cli.js +0 -64
  12. package/lib/index.d.ts +0 -1775
  13. package/lib/index.js +0 -42
  14. package/lib/model/Account.js +0 -381
  15. package/lib/model/Amount.js +0 -295
  16. package/lib/model/App.js +0 -95
  17. package/lib/model/Bkper.js +0 -101
  18. package/lib/model/Book.js +0 -713
  19. package/lib/model/Collection.js +0 -43
  20. package/lib/model/Config.js +0 -3
  21. package/lib/model/Connection.js +0 -257
  22. package/lib/model/Enums.js +0 -138
  23. package/lib/model/File.js +0 -124
  24. package/lib/model/Group.js +0 -244
  25. package/lib/model/Integration.js +0 -112
  26. package/lib/model/Transaction.js +0 -715
  27. package/lib/model/TransactionIterator.js +0 -154
  28. package/lib/model/TransactionPage.js +0 -93
  29. package/lib/model/User.js +0 -93
  30. package/lib/service/account-service.js +0 -43
  31. package/lib/service/app-service.js +0 -35
  32. package/lib/service/balances-service.js +0 -21
  33. package/lib/service/book-service.js +0 -37
  34. package/lib/service/connection-service.js +0 -72
  35. package/lib/service/file-service.js +0 -28
  36. package/lib/service/group-service.js +0 -72
  37. package/lib/service/http-api-request.js +0 -169
  38. package/lib/service/integration-service.js +0 -53
  39. package/lib/service/transaction-service.js +0 -115
  40. package/lib/service/user-service.js +0 -21
  41. package/lib/tsdoc-metadata.json +0 -11
  42. package/lib/utils.js +0 -341
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Collection = void 0;
4
- const Book_1 = require("./Book");
5
- /**
6
- * This class defines a Collection of [[Books]].
7
- *
8
- * @public
9
- */
10
- class Collection {
11
- /** @internal */
12
- constructor(wrapped) {
13
- this.wrapped = wrapped;
14
- }
15
- /**
16
- * @returns The id of this Collection
17
- */
18
- getId() {
19
- return this.wrapped.id;
20
- }
21
- /**
22
- * @returns The name of this Collection
23
- */
24
- getName() {
25
- return this.wrapped.name;
26
- }
27
- /**
28
- * @returns All Books of this collection.
29
- */
30
- getBooks() {
31
- let books = [];
32
- if (this.wrapped.books == null) {
33
- return books;
34
- }
35
- for (const bookPayload of this.wrapped.books) {
36
- let book = new Book_1.Book(bookPayload);
37
- books.push(book);
38
- }
39
- return books;
40
- }
41
- }
42
- exports.Collection = Collection;
43
- //# sourceMappingURL=Collection.js.map
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Config.js.map
@@ -1,257 +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.Connection = void 0;
32
- const ConnectionService = __importStar(require("../service/connection-service"));
33
- const Integration_1 = require("./Integration");
34
- /**
35
- * This class defines a Connection from an [[User]] to an external service.
36
- *
37
- * @public
38
- */
39
- class Connection {
40
- constructor(json) {
41
- this.wrapped = json || {};
42
- }
43
- /**
44
- * Gets the wrapped plain json object of the Connection.
45
- *
46
- * @returns The Connection wrapped plain json object
47
- */
48
- json() {
49
- return this.wrapped;
50
- }
51
- /**
52
- * Gets the id of the Connection.
53
- *
54
- * @returns The Connection's id
55
- */
56
- getId() {
57
- return this.wrapped.id;
58
- }
59
- /**
60
- * Gets the agentId of the Connection.
61
- *
62
- * @returns The Connection's agentId
63
- */
64
- getAgentId() {
65
- return this.wrapped.agentId;
66
- }
67
- /**
68
- * Sets the Connection agentId.
69
- *
70
- * @param agentId - The Connection agentId
71
- *
72
- * @returns The Connection, for chainning
73
- */
74
- setAgentId(agentId) {
75
- this.wrapped.agentId = agentId;
76
- return this;
77
- }
78
- /**
79
- * Gets the name of the Connection.
80
- *
81
- * @returns The Connection name
82
- */
83
- getName() {
84
- return this.wrapped.name;
85
- }
86
- /**
87
- * Gets the email of the owner of the Connection.
88
- *
89
- * @returns The Connection owner's email
90
- */
91
- getEmail() {
92
- return this.wrapped.email;
93
- }
94
- /**
95
- * Sets the name of the Connection.
96
- *
97
- * @param name - The name of the Connection
98
- *
99
- * @returns The Connection, for chainning
100
- */
101
- setName(name) {
102
- this.wrapped.name = name;
103
- return this;
104
- }
105
- /**
106
- * Sets the universal unique identifier of the Connection.
107
- *
108
- * @param uuid - The universal unique identifier of the Connection
109
- *
110
- * @returns The Connection, for chainning
111
- */
112
- setUUID(uuid) {
113
- this.wrapped.uuid = uuid;
114
- return this;
115
- }
116
- /**
117
- * Gets the universal unique identifier of this Connection.
118
- *
119
- * @returns The Connection's universal unique identifier name
120
- */
121
- getUUID() {
122
- return this.wrapped.uuid;
123
- }
124
- /**
125
- * Gets the type of the Connection.
126
- *
127
- * @returns The Connection type
128
- */
129
- getType() {
130
- return this.wrapped.type;
131
- }
132
- /**
133
- * Sets the Connection type.
134
- *
135
- * @param type - The Connection type
136
- *
137
- * @returns The Connection, for chainning
138
- */
139
- setType(type) {
140
- this.wrapped.type = type;
141
- return this;
142
- }
143
- /**
144
- * Gets the custom properties stored in the Connection
145
- *
146
- * @returns Object with key/value pair properties
147
- */
148
- getProperties() {
149
- return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
150
- }
151
- /**
152
- * Sets the custom properties of the Connection.
153
- *
154
- * @param properties - Object with key/value pair properties
155
- *
156
- * @returns The Connection, for chainning
157
- */
158
- setProperties(properties) {
159
- this.wrapped.properties = Object.assign({}, properties);
160
- return this;
161
- }
162
- /**
163
- * Gets the property value for given keys. First property found will be retrieved.
164
- *
165
- * @param keys - The property key
166
- *
167
- * @returns The retrieved property value
168
- */
169
- getProperty(...keys) {
170
- for (let index = 0; index < keys.length; index++) {
171
- const key = keys[index];
172
- let value = this.wrapped.properties != null ? this.wrapped.properties[key] : null;
173
- if (value != null && value.trim() != '') {
174
- return value;
175
- }
176
- }
177
- return null;
178
- }
179
- /**
180
- * Sets a custom property in the Connection.
181
- *
182
- * @param key - The property key
183
- * @param value - The property value
184
- *
185
- * @returns The Connection, for chaining
186
- */
187
- setProperty(key, value) {
188
- if (key == null || key.trim() == '') {
189
- return this;
190
- }
191
- if (this.wrapped.properties == null) {
192
- this.wrapped.properties = {};
193
- }
194
- this.wrapped.properties[key] = value;
195
- return this;
196
- }
197
- /**
198
- * Deletes a custom property stored in the Connection.
199
- *
200
- * @param key - The property key
201
- *
202
- * @returns The Connection, for chainning
203
- */
204
- deleteProperty(key) {
205
- this.setProperty(key, null);
206
- return this;
207
- }
208
- /**
209
- * Cleans any token property stored in the Connection.
210
- */
211
- clearTokenProperties() {
212
- this.getPropertyKeys().filter(key => key.includes("token")).forEach(key => this.deleteProperty(key));
213
- }
214
- /**
215
- * Gets the custom properties keys stored in the Connection.
216
- *
217
- * @returns The retrieved property keys
218
- */
219
- getPropertyKeys() {
220
- let properties = this.getProperties();
221
- let propertyKeys = [];
222
- if (properties) {
223
- for (var key in properties) {
224
- if (Object.prototype.hasOwnProperty.call(properties, key)) {
225
- propertyKeys.push(key);
226
- }
227
- }
228
- }
229
- propertyKeys = propertyKeys.sort();
230
- return propertyKeys;
231
- }
232
- /**
233
- * Gets the existing [[Integrations]] on the Connection.
234
- *
235
- * @returns The existing Integration objects
236
- */
237
- getIntegrations() {
238
- return __awaiter(this, void 0, void 0, function* () {
239
- const integrationsPlain = yield ConnectionService.listIntegrations(this.getId());
240
- const integrations = integrationsPlain.map(i => new Integration_1.Integration(i));
241
- return integrations;
242
- });
243
- }
244
- /**
245
- * Performs create new Connection.
246
- *
247
- * @returns The Connection, for chaining
248
- */
249
- create() {
250
- return __awaiter(this, void 0, void 0, function* () {
251
- this.wrapped = yield ConnectionService.createConnection(this.wrapped);
252
- return this;
253
- });
254
- }
255
- }
256
- exports.Connection = Connection;
257
- //# sourceMappingURL=Connection.js.map
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Month = exports.Period = exports.AccountType = exports.Permission = exports.DecimalSeparator = exports.Periodicity = void 0;
4
- /**
5
- * The Periodicity of the query. It may depend on the level of granularity you write the range params.
6
- *
7
- * @public
8
- */
9
- var Periodicity;
10
- (function (Periodicity) {
11
- /**
12
- * Example: after:25/01/1983, before:04/03/2013, after:$d-30, before:$d, after:$d-15/$m
13
- */
14
- Periodicity["DAILY"] = "DAILY";
15
- /**
16
- * Example: after:jan/2013, before:mar/2013, after:$m-1, before:$m
17
- */
18
- Periodicity["MONTHLY"] = "MONTHLY";
19
- /**
20
- * Example: on:2013, after:2013, $y
21
- */
22
- Periodicity["YEARLY"] = "YEARLY";
23
- })(Periodicity = exports.Periodicity || (exports.Periodicity = {}));
24
- /**
25
- * Decimal separator of numbers on book
26
- *
27
- * @public
28
- */
29
- var DecimalSeparator;
30
- (function (DecimalSeparator) {
31
- /**
32
- * ,
33
- */
34
- DecimalSeparator["COMMA"] = "COMMA";
35
- /**
36
- * .
37
- */
38
- DecimalSeparator["DOT"] = "DOT";
39
- })(DecimalSeparator = exports.DecimalSeparator || (exports.DecimalSeparator = {}));
40
- /**
41
- * Enum representing permissions of user in the Book
42
- *
43
- * Learn more at [share article](https://help.bkper.com/en/articles/2569153-share-your-book-with-your-peers).
44
- *
45
- * @public
46
- */
47
- var Permission;
48
- (function (Permission) {
49
- /**
50
- * No permission
51
- */
52
- Permission["NONE"] = "NONE";
53
- /**
54
- * View transactions, accounts and balances.
55
- */
56
- Permission["VIEWER"] = "VIEWER";
57
- /**
58
- * Record and delete drafts only. Useful to collect data only
59
- */
60
- Permission["RECORDER"] = "RECORDER";
61
- /**
62
- * View transactions, accounts, record and delete drafts
63
- */
64
- Permission["POSTER"] = "POSTER";
65
- /**
66
- * Manage accounts, transactions, book configuration and sharing
67
- */
68
- Permission["EDITOR"] = "EDITOR";
69
- /**
70
- * Manage everything, including book visibility and deletion. Only one owner per book.
71
- */
72
- Permission["OWNER"] = "OWNER";
73
- })(Permission = exports.Permission || (exports.Permission = {}));
74
- /**
75
- * Enum that represents account types.
76
- *
77
- * @public
78
- */
79
- var AccountType;
80
- (function (AccountType) {
81
- /**
82
- * Asset account type
83
- */
84
- AccountType["ASSET"] = "ASSET";
85
- /**
86
- * Liability account type
87
- */
88
- AccountType["LIABILITY"] = "LIABILITY";
89
- /**
90
- * Incoming account type
91
- */
92
- AccountType["INCOMING"] = "INCOMING";
93
- /**
94
- * Outgoing account type
95
- */
96
- AccountType["OUTGOING"] = "OUTGOING";
97
- })(AccountType = exports.AccountType || (exports.AccountType = {}));
98
- /**
99
- * Enum that represents a period slice.
100
- *
101
- * @public
102
- */
103
- var Period;
104
- (function (Period) {
105
- /**
106
- * Monthly period
107
- */
108
- Period["MONTH"] = "MONTH";
109
- /**
110
- * Quarterly period
111
- */
112
- Period["QUARTER"] = "QUARTER";
113
- /**
114
- * Yearly period
115
- */
116
- Period["YEAR"] = "YEAR";
117
- })(Period = exports.Period || (exports.Period = {}));
118
- /**
119
- * Enum that represents a Month.
120
- *
121
- * @public
122
- */
123
- var Month;
124
- (function (Month) {
125
- Month["JANUARY"] = "JANUARY";
126
- Month["FEBRUARY"] = "FEBRUARY";
127
- Month["MARCH"] = "MARCH";
128
- Month["APRIL"] = "APRIL";
129
- Month["MAY"] = "MAY";
130
- Month["JUNE"] = "JUNE";
131
- Month["JULY"] = "JULY";
132
- Month["AUGUST"] = "AUGUST";
133
- Month["SEPTEMBER"] = "SEPTEMBER";
134
- Month["OCTOBER"] = "OCTOBER";
135
- Month["NOVEMBER"] = "NOVEMBER";
136
- Month["DECEMBER"] = "DECEMBER";
137
- })(Month = exports.Month || (exports.Month = {}));
138
- //# sourceMappingURL=Enums.js.map
package/lib/model/File.js DELETED
@@ -1,124 +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.File = void 0;
32
- const FileService = __importStar(require("../service/file-service"));
33
- /**
34
- *
35
- * This class defines a File uploaded to a [[Book]].
36
- *
37
- * A File can be attached to a [[Transaction]] or used to import data.
38
- *
39
- * @public
40
- */
41
- class File {
42
- /**
43
- * Gets the File id
44
- */
45
- getId() {
46
- return this.wrapped.id;
47
- }
48
- /**
49
- * Gets the File name
50
- */
51
- getName() {
52
- return this.wrapped.name;
53
- }
54
- /**
55
- *
56
- * Sets the name of the File.
57
- *
58
- * @returns This File, for chainning.
59
- */
60
- setName(name) {
61
- this.wrapped.name = name;
62
- return this;
63
- }
64
- /**
65
- * Gets the File content type
66
- */
67
- getContentType() {
68
- return this.wrapped.contentType;
69
- }
70
- /**
71
- *
72
- * Sets the File content type.
73
- *
74
- * @returns This File, for chainning.
75
- */
76
- setContentType(contentType) {
77
- this.wrapped.contentType = contentType;
78
- return this;
79
- }
80
- /**
81
- * Gets the file content Base64 encoded
82
- */
83
- getContent() {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- if (this.getId() != null && (this.wrapped == null || this.wrapped.content == null)) {
86
- this.wrapped = yield FileService.getFile(this.book.getId(), this.getId());
87
- }
88
- return this.wrapped.content;
89
- });
90
- }
91
- /**
92
- *
93
- * Sets the File content Base64 encoded.
94
- *
95
- * @returns This File, for chainning.
96
- */
97
- setContent(content) {
98
- this.wrapped.content = content;
99
- return this;
100
- }
101
- /**
102
- * Gets the file serving url for accessing via browser
103
- */
104
- getUrl() {
105
- return this.wrapped.url;
106
- }
107
- /**
108
- * Gets the file size in bytes
109
- */
110
- getSize() {
111
- return this.wrapped.size;
112
- }
113
- /**
114
- * Perform create new File.
115
- */
116
- create() {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- this.wrapped = yield FileService.createFile(this.book.getId(), this.wrapped);
119
- return this;
120
- });
121
- }
122
- }
123
- exports.File = File;
124
- //# sourceMappingURL=File.js.map