bkper 2.7.1 → 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 +10 -33
  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/HttpApiRequest.js +0 -170
  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/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,295 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Amount = void 0;
7
- const big_js_1 = __importDefault(require("big.js"));
8
- /**
9
- * This class defines an Amount for arbitrary-precision decimal arithmetic.
10
- *
11
- * It inherits methods from [big.js](http://mikemcl.github.io/big.js/) library
12
- *
13
- * @public
14
- */
15
- class Amount {
16
- /**
17
- * The Amount constructor.
18
- */
19
- constructor(n) {
20
- this.checkNumberNotNull(n);
21
- if (typeof n == "string") {
22
- this.wrapped = new big_js_1.default(n);
23
- }
24
- else if (n instanceof Amount) {
25
- this.wrapped = new big_js_1.default(n.wrapped);
26
- }
27
- else if (n.toString) {
28
- this.wrapped = new big_js_1.default(n.toString());
29
- }
30
- else {
31
- this.wrapped = new big_js_1.default(+n);
32
- }
33
- }
34
- /**
35
- * Returns an absolute Amount.
36
- */
37
- abs() {
38
- let big = this.wrapped.abs();
39
- return this.wrap(big);
40
- }
41
- /**
42
- * Compare
43
- */
44
- cmp(n) {
45
- this.checkNumberNotNull(n);
46
- if (typeof n == "string") {
47
- return this.wrapped.cmp(n);
48
- }
49
- else if (n instanceof Amount) {
50
- return this.wrapped.cmp(n.wrapped);
51
- }
52
- else if (n.toString) {
53
- return this.wrapped.cmp(n.toString());
54
- }
55
- else {
56
- return this.wrapped.cmp(+n);
57
- }
58
- }
59
- /**
60
- * Divide by
61
- */
62
- div(n) {
63
- this.checkNumberNotNull(n);
64
- let big;
65
- if (typeof n == "string") {
66
- big = this.wrapped.div(n);
67
- }
68
- else if (n instanceof Amount) {
69
- big = this.wrapped.div(n.wrapped);
70
- }
71
- else if (n.toString) {
72
- big = this.wrapped.div(n.toString());
73
- }
74
- else {
75
- big = this.wrapped.div(+n);
76
- }
77
- return this.wrap(big);
78
- }
79
- /**
80
- * Equals to
81
- */
82
- eq(n) {
83
- this.checkNumberNotNull(n);
84
- if (typeof n == "string") {
85
- return this.wrapped.eq(n);
86
- }
87
- else if (n instanceof Amount) {
88
- return this.wrapped.eq(n.wrapped);
89
- }
90
- else if (n.toString) {
91
- return this.wrapped.eq(n.toString());
92
- }
93
- else {
94
- return this.wrapped.eq(+n);
95
- }
96
- }
97
- /**
98
- * Greater than
99
- */
100
- gt(n) {
101
- this.checkNumberNotNull(n);
102
- if (typeof n == "string") {
103
- return this.wrapped.gt(n);
104
- }
105
- else if (n instanceof Amount) {
106
- return this.wrapped.gt(n.wrapped);
107
- }
108
- else if (n.toString) {
109
- return this.wrapped.gt(n.toString());
110
- }
111
- else {
112
- return this.wrapped.gt(+n);
113
- }
114
- }
115
- /**
116
- * Greater than or equal
117
- */
118
- gte(n) {
119
- this.checkNumberNotNull(n);
120
- if (typeof n == "string") {
121
- return this.wrapped.gte(n);
122
- }
123
- else if (n instanceof Amount) {
124
- return this.wrapped.gte(n.wrapped);
125
- }
126
- else if (n.toString) {
127
- return this.wrapped.gte(n.toString());
128
- }
129
- else {
130
- return this.wrapped.gte(+n);
131
- }
132
- }
133
- /**
134
- * Less than
135
- */
136
- lt(n) {
137
- this.checkNumberNotNull(n);
138
- if (typeof n == "string") {
139
- return this.wrapped.lt(n);
140
- }
141
- else if (n instanceof Amount) {
142
- return this.wrapped.lt(n.wrapped);
143
- }
144
- else if (n.toString) {
145
- return this.wrapped.lt(n.toString());
146
- }
147
- else {
148
- return this.wrapped.lt(+n);
149
- }
150
- }
151
- /**
152
- * Less than or equal to
153
- */
154
- lte(n) {
155
- this.checkNumberNotNull(n);
156
- if (typeof n == "string") {
157
- return this.wrapped.lte(n);
158
- }
159
- else if (n instanceof Amount) {
160
- return this.wrapped.lte(n.wrapped);
161
- }
162
- else if (n.toString) {
163
- return this.wrapped.lte(n.toString());
164
- }
165
- else {
166
- return this.wrapped.lte(+n);
167
- }
168
- }
169
- /**
170
- * Sum
171
- */
172
- plus(n) {
173
- this.checkNumberNotNull(n);
174
- let big;
175
- if (typeof n == "string") {
176
- big = this.wrapped.plus(n);
177
- }
178
- else if (n instanceof Amount) {
179
- big = this.wrapped.plus(n.wrapped);
180
- }
181
- else if (n.toString) {
182
- big = this.wrapped.plus(n.toString());
183
- }
184
- else {
185
- big = this.wrapped.plus(+n);
186
- }
187
- return this.wrap(big);
188
- }
189
- /**
190
- * Minus
191
- */
192
- minus(n) {
193
- this.checkNumberNotNull(n);
194
- let big;
195
- if (typeof n == "string") {
196
- big = this.wrapped.minus(n);
197
- }
198
- else if (n instanceof Amount) {
199
- big = this.wrapped.minus(n.wrapped);
200
- }
201
- else if (n.toString) {
202
- big = this.wrapped.minus(n.toString());
203
- }
204
- else {
205
- big = this.wrapped.minus(+n);
206
- }
207
- return this.wrap(big);
208
- }
209
- /**
210
- * Modulo - the integer remainder of dividing this Amount by n.
211
- *
212
- * Similar to % operator
213
- *
214
- */
215
- mod(n) {
216
- this.checkNumberNotNull(n);
217
- let big;
218
- if (typeof n == "string") {
219
- big = this.wrapped.mod(n);
220
- }
221
- else if (n instanceof Amount) {
222
- big = this.wrapped.mod(n.wrapped);
223
- }
224
- else if (n.toString) {
225
- big = this.wrapped.mod(n.toString());
226
- }
227
- else {
228
- big = this.wrapped.mod(+n);
229
- }
230
- return this.wrap(big);
231
- }
232
- /**
233
- * Round to a maximum of dp decimal places.
234
- */
235
- round(dp) {
236
- let big = this.wrapped.round(dp);
237
- return this.wrap(big);
238
- }
239
- /**
240
- * Multiply
241
- */
242
- times(n) {
243
- this.checkNumberNotNull(n);
244
- let big;
245
- if (typeof n == "string") {
246
- big = this.wrapped.times(n);
247
- }
248
- else if (n instanceof Amount) {
249
- big = this.wrapped.times(n.wrapped);
250
- }
251
- else if (n.toString) {
252
- big = this.wrapped.times(n.toString());
253
- }
254
- else {
255
- big = this.wrapped.times(+n);
256
- }
257
- return this.wrap(big);
258
- }
259
- /**
260
- * Returns a string representing the value of this Amount in normal notation to a fixed number of decimal places dp.
261
- */
262
- toFixed(dp) {
263
- return this.wrapped.toFixed(dp);
264
- }
265
- /**
266
- * Returns a string representing the value of this Amount.
267
- */
268
- toString() {
269
- return this.wrapped.toString();
270
- }
271
- /**
272
- * Returns a primitive number representing the value of this Amount.
273
- */
274
- toNumber() {
275
- return this.wrapped.toNumber();
276
- }
277
- /** @internal */
278
- checkNumberNotNull(amount) {
279
- if (amount == null) {
280
- throw new Error(`Invalid number: null`);
281
- }
282
- }
283
- /** @internal */
284
- static create() {
285
- return Object.create(this.prototype);
286
- }
287
- /** @internal */
288
- wrap(big) {
289
- let amount = Amount.create();
290
- amount.wrapped = big;
291
- return amount;
292
- }
293
- }
294
- exports.Amount = Amount;
295
- //# sourceMappingURL=Amount.js.map
package/lib/model/App.js DELETED
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.App = void 0;
13
- const app_service_1 = require("../service/app-service");
14
- /**
15
- * Defines an App on Bkper.
16
- *
17
- * Apps can be installed on Books by users.
18
- *
19
- * @public
20
- */
21
- class App {
22
- /** @internal */
23
- constructor() {
24
- this.wrapped = {};
25
- }
26
- /**
27
- *
28
- * Sets the webhook url for development.
29
- *
30
- * @returns This App, for chainning.
31
- */
32
- setWebhookUrlDev(webhookUrlDev) {
33
- if (webhookUrlDev) {
34
- this.wrapped.webhookUrlDev = webhookUrlDev;
35
- }
36
- else {
37
- this.wrapped.webhookUrlDev = 'null';
38
- }
39
- return this;
40
- }
41
- /**
42
- * Partially update an App, applying pending changes.
43
- */
44
- patch() {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- yield app_service_1.patchApp(this.wrapped);
47
- return this;
48
- });
49
- }
50
- /** @internal */
51
- update() {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- yield app_service_1.updateApp(this.wrapped);
54
- return this;
55
- });
56
- }
57
- /** @internal */
58
- setJson(json) {
59
- this.wrapped = json;
60
- return this;
61
- }
62
- /** @internal */
63
- getId() {
64
- return this.wrapped.id;
65
- }
66
- /** @internal */
67
- setUserEmails(emails) {
68
- this.wrapped.userEmails = emails;
69
- return this;
70
- }
71
- /** @internal */
72
- setDeveloperEmail(email) {
73
- this.wrapped.developerEmail = email;
74
- return this;
75
- }
76
- /** @internal */
77
- setClientSecret(clientSecret) {
78
- this.wrapped.clientSecret = clientSecret;
79
- return this;
80
- }
81
- /** @internal */
82
- setReadme(readme) {
83
- this.wrapped.readme = readme;
84
- return this;
85
- }
86
- /** @internal */
87
- create() {
88
- return __awaiter(this, void 0, void 0, function* () {
89
- yield app_service_1.createApp(this.wrapped);
90
- return this;
91
- });
92
- }
93
- }
94
- exports.App = App;
95
- //# sourceMappingURL=App.js.map
@@ -1,101 +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.Bkper = void 0;
32
- const Book_1 = require("./Book");
33
- const App_1 = require("./App");
34
- const BookService = __importStar(require("../service/book-service"));
35
- const UserService = __importStar(require("../service/user-service"));
36
- const HttpApiRequest_1 = require("../service/HttpApiRequest");
37
- const User_1 = require("./User");
38
- /**
39
- * This is the main Entry Point of the [bkper-node](https://www.npmjs.com/package/bkper) library.
40
- *
41
- * @public
42
- */
43
- class Bkper {
44
- /**
45
- * Gets the [[Book]] with the specified bookId from url param.
46
- *
47
- * @param id - The universal book id - The same bookId param of URL you access at app.bkper.com
48
- *
49
- * @returns The retrieved Book, for chaining
50
- */
51
- static getBook(id) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- let book = yield BookService.loadBook(id);
54
- return new Book_1.Book(book);
55
- });
56
- }
57
- /**
58
- * Gets the current logged [[User]].
59
- *
60
- * @returns The retrieved User, for chaining
61
- */
62
- static getUser() {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- let user = yield UserService.getUser();
65
- return new User_1.User(user);
66
- });
67
- }
68
- /**
69
- * Sets the API [[Config]] object.
70
- *
71
- * @param config - The Config object
72
- */
73
- static setConfig(config) {
74
- HttpApiRequest_1.HttpApiRequest.config = config;
75
- }
76
- /**
77
- * Sets the API key to identify the agent.
78
- *
79
- * @param key - The API key
80
- *
81
- * @returns The defined [[App]] object
82
- *
83
- * @deprecated Use `setConfig()` instead
84
- */
85
- static setApiKey(key) {
86
- HttpApiRequest_1.HttpApiRequest.config.apiKeyProvider = () => __awaiter(this, void 0, void 0, function* () { return key; });
87
- return new App_1.App();
88
- }
89
- /**
90
- * Sets the provider of the valid OAuth2 access token
91
- *
92
- * @deprecated Use `setConfig()` instead
93
- */
94
- static setOAuthTokenProvider(oauthTokenProvider) {
95
- return __awaiter(this, void 0, void 0, function* () {
96
- HttpApiRequest_1.HttpApiRequest.config.oauthTokenProvider = oauthTokenProvider;
97
- });
98
- }
99
- }
100
- exports.Bkper = Bkper;
101
- //# sourceMappingURL=Bkper.js.map