bkper-js 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/lib/index.d.ts +115 -97
- package/lib/index.js +15 -35
- package/lib/model/Account.js +30 -50
- package/lib/model/Amount.js +6 -13
- package/lib/model/App.js +6 -10
- package/lib/model/Bkper.js +14 -41
- package/lib/model/Book.js +64 -103
- package/lib/model/Collection.js +5 -9
- package/lib/model/Config.js +1 -2
- package/lib/model/Connection.js +8 -32
- package/lib/model/Enums.js +12 -15
- package/lib/model/File.js +19 -32
- package/lib/model/Group.js +16 -40
- package/lib/model/Integration.js +6 -7
- package/lib/model/Transaction.js +59 -77
- package/lib/model/TransactionIterator.js +15 -19
- package/lib/model/TransactionPage.js +14 -40
- package/lib/model/User.js +9 -34
- package/lib/service/account-service.js +9 -15
- package/lib/service/app-service.js +7 -12
- package/lib/service/balances-service.js +3 -6
- package/lib/service/book-service.js +7 -12
- package/lib/service/connection-service.js +16 -21
- package/lib/service/file-service.js +5 -9
- package/lib/service/group-service.js +18 -24
- package/lib/service/http-api-request.js +50 -101
- package/lib/service/http-request.js +78 -0
- package/lib/service/integration-service.js +9 -15
- package/lib/service/transaction-service.js +27 -37
- package/lib/service/user-service.js +3 -6
- package/lib/utils.js +72 -85
- package/package.json +9 -7
package/lib/model/Book.js
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,23 +7,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
8
|
});
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const TransactionIterator_1 = require("./TransactionIterator");
|
|
50
|
-
const Integration_1 = require("./Integration");
|
|
10
|
+
import * as AccountService from '../service/account-service.js';
|
|
11
|
+
import * as GroupService from '../service/group-service.js';
|
|
12
|
+
import * as BookService from '../service/book-service.js';
|
|
13
|
+
import * as FileService from '../service/file-service.js';
|
|
14
|
+
import * as TransactionService from '../service/transaction-service.js';
|
|
15
|
+
import * as IntegrationService from '../service/integration-service.js';
|
|
16
|
+
import * as Utils from '../utils.js';
|
|
17
|
+
import { normalizeName } from '../utils.js';
|
|
18
|
+
import { Account } from './Account.js';
|
|
19
|
+
import { Collection } from './Collection.js';
|
|
20
|
+
import { File } from './File.js';
|
|
21
|
+
import { Group } from './Group.js';
|
|
22
|
+
import { Transaction } from './Transaction.js';
|
|
23
|
+
import { TransactionIterator } from './TransactionIterator.js';
|
|
24
|
+
import { Integration } from './Integration.js';
|
|
51
25
|
/**
|
|
52
26
|
*
|
|
53
27
|
* A Book represents [General Ledger](https://en.wikipedia.org/wiki/General_ledger) for a company or business, but can also represent a [Ledger](https://en.wikipedia.org/wiki/Ledger) for a project or department
|
|
@@ -56,9 +30,9 @@ const Integration_1 = require("./Integration");
|
|
|
56
30
|
*
|
|
57
31
|
* @public
|
|
58
32
|
*/
|
|
59
|
-
class Book {
|
|
33
|
+
export class Book {
|
|
60
34
|
constructor(json) {
|
|
61
|
-
this.wrapped = json;
|
|
35
|
+
this.wrapped = json || {};
|
|
62
36
|
}
|
|
63
37
|
/**
|
|
64
38
|
* @returns The wrapped plain json object
|
|
@@ -70,7 +44,7 @@ class Book {
|
|
|
70
44
|
* Same as bookId param
|
|
71
45
|
*/
|
|
72
46
|
getId() {
|
|
73
|
-
return this.wrapped.id;
|
|
47
|
+
return this.wrapped.id || '';
|
|
74
48
|
}
|
|
75
49
|
/**
|
|
76
50
|
* @returns The name of this Book
|
|
@@ -172,7 +146,7 @@ class Book {
|
|
|
172
146
|
*/
|
|
173
147
|
getCollection() {
|
|
174
148
|
if (this.wrapped.collection != null && this.collection == null) {
|
|
175
|
-
this.collection = new
|
|
149
|
+
this.collection = new Collection(this.wrapped.collection);
|
|
176
150
|
}
|
|
177
151
|
return this.collection;
|
|
178
152
|
}
|
|
@@ -272,7 +246,7 @@ class Book {
|
|
|
272
246
|
* @returns The last update date of the book, in in milliseconds
|
|
273
247
|
*/
|
|
274
248
|
getLastUpdateMs() {
|
|
275
|
-
return +this.wrapped.lastUpdateMs;
|
|
249
|
+
return this.wrapped.lastUpdateMs ? +this.wrapped.lastUpdateMs : undefined;
|
|
276
250
|
}
|
|
277
251
|
/**
|
|
278
252
|
* Gets the custom properties stored in this Book
|
|
@@ -293,7 +267,7 @@ class Book {
|
|
|
293
267
|
return value;
|
|
294
268
|
}
|
|
295
269
|
}
|
|
296
|
-
return
|
|
270
|
+
return undefined;
|
|
297
271
|
}
|
|
298
272
|
/**
|
|
299
273
|
* Sets the custom properties of the Book
|
|
@@ -321,6 +295,9 @@ class Book {
|
|
|
321
295
|
if (this.wrapped.properties == null) {
|
|
322
296
|
this.wrapped.properties = {};
|
|
323
297
|
}
|
|
298
|
+
if (!value) {
|
|
299
|
+
value = '';
|
|
300
|
+
}
|
|
324
301
|
this.wrapped.properties[key] = value;
|
|
325
302
|
return this;
|
|
326
303
|
}
|
|
@@ -381,10 +358,9 @@ class Book {
|
|
|
381
358
|
batchCreateTransactions(transactions) {
|
|
382
359
|
return __awaiter(this, void 0, void 0, function* () {
|
|
383
360
|
let transactionPayloads = [];
|
|
384
|
-
transactions.forEach(tx => transactionPayloads.push(tx.
|
|
361
|
+
transactions.forEach(tx => transactionPayloads.push(tx.json()));
|
|
385
362
|
transactionPayloads = yield TransactionService.createTransactionsBatch(this.getId(), transactionPayloads);
|
|
386
|
-
transactions =
|
|
387
|
-
this.configureTransactions_(transactions);
|
|
363
|
+
transactions = transactionPayloads.map(tx => new Transaction(this, tx));
|
|
388
364
|
return transactions;
|
|
389
365
|
});
|
|
390
366
|
}
|
|
@@ -394,7 +370,7 @@ class Book {
|
|
|
394
370
|
batchTrashTransactions(transactions) {
|
|
395
371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
396
372
|
let transactionPayloads = [];
|
|
397
|
-
transactions.forEach(tx => transactionPayloads.push(tx.
|
|
373
|
+
transactions.forEach(tx => transactionPayloads.push(tx.json()));
|
|
398
374
|
yield TransactionService.trashTransactionsBatch(this.getId(), transactionPayloads);
|
|
399
375
|
});
|
|
400
376
|
}
|
|
@@ -412,7 +388,7 @@ class Book {
|
|
|
412
388
|
getIntegrations() {
|
|
413
389
|
return __awaiter(this, void 0, void 0, function* () {
|
|
414
390
|
const integrationsPlain = yield IntegrationService.listIntegrations(this.getId());
|
|
415
|
-
const integrations = integrationsPlain.map(i => new
|
|
391
|
+
const integrations = integrationsPlain.map(i => new Integration(i));
|
|
416
392
|
return integrations;
|
|
417
393
|
});
|
|
418
394
|
}
|
|
@@ -425,13 +401,13 @@ class Book {
|
|
|
425
401
|
*/
|
|
426
402
|
createIntegration(integration) {
|
|
427
403
|
return __awaiter(this, void 0, void 0, function* () {
|
|
428
|
-
if (integration instanceof
|
|
404
|
+
if (integration instanceof Integration) {
|
|
429
405
|
integration = yield IntegrationService.createIntegration(this.getId(), integration.json());
|
|
430
406
|
}
|
|
431
407
|
else {
|
|
432
408
|
integration = yield IntegrationService.createIntegration(this.getId(), integration);
|
|
433
409
|
}
|
|
434
|
-
return new
|
|
410
|
+
return new Integration(integration);
|
|
435
411
|
});
|
|
436
412
|
}
|
|
437
413
|
/**
|
|
@@ -443,13 +419,13 @@ class Book {
|
|
|
443
419
|
*/
|
|
444
420
|
updateIntegration(integration) {
|
|
445
421
|
return __awaiter(this, void 0, void 0, function* () {
|
|
446
|
-
if (integration instanceof
|
|
422
|
+
if (integration instanceof Integration) {
|
|
447
423
|
integration = yield IntegrationService.updateIntegration(this.getId(), integration.json());
|
|
448
424
|
}
|
|
449
425
|
else {
|
|
450
426
|
integration = yield IntegrationService.updateIntegration(this.getId(), integration);
|
|
451
427
|
}
|
|
452
|
-
return new
|
|
428
|
+
return new Integration(integration);
|
|
453
429
|
});
|
|
454
430
|
}
|
|
455
431
|
/**
|
|
@@ -460,21 +436,10 @@ class Book {
|
|
|
460
436
|
* @returns a collection of transactions that remained in a previous iterator when the continuation token was generated
|
|
461
437
|
*/
|
|
462
438
|
continueTransactionIterator(query, continuationToken) {
|
|
463
|
-
var transactionIterator = new
|
|
439
|
+
var transactionIterator = new TransactionIterator(this, query);
|
|
464
440
|
transactionIterator.setContinuationToken(continuationToken);
|
|
465
441
|
return transactionIterator;
|
|
466
442
|
}
|
|
467
|
-
configureTransactions_(transactions) {
|
|
468
|
-
for (var i = 0; i < transactions.length; i++) {
|
|
469
|
-
this.configureTransaction_(transactions[i]);
|
|
470
|
-
}
|
|
471
|
-
return transactions;
|
|
472
|
-
}
|
|
473
|
-
/** @internal */
|
|
474
|
-
configureTransaction_(transaction) {
|
|
475
|
-
transaction.book = this;
|
|
476
|
-
return transaction;
|
|
477
|
-
}
|
|
478
443
|
/**
|
|
479
444
|
* Instantiate a new [[Transaction]]
|
|
480
445
|
*
|
|
@@ -495,8 +460,7 @@ class Book {
|
|
|
495
460
|
*
|
|
496
461
|
*/
|
|
497
462
|
newTransaction() {
|
|
498
|
-
let transaction =
|
|
499
|
-
this.configureTransaction_(transaction);
|
|
463
|
+
let transaction = new Transaction(this, {});
|
|
500
464
|
return transaction;
|
|
501
465
|
}
|
|
502
466
|
/**
|
|
@@ -515,9 +479,8 @@ class Book {
|
|
|
515
479
|
* ```
|
|
516
480
|
*/
|
|
517
481
|
newAccount() {
|
|
518
|
-
let account =
|
|
482
|
+
let account = new Account(this, {});
|
|
519
483
|
account.setArchived(false);
|
|
520
|
-
account.book = this;
|
|
521
484
|
return account;
|
|
522
485
|
}
|
|
523
486
|
/**
|
|
@@ -534,8 +497,7 @@ class Book {
|
|
|
534
497
|
* ```
|
|
535
498
|
*/
|
|
536
499
|
newGroup() {
|
|
537
|
-
let group =
|
|
538
|
-
group.book = this;
|
|
500
|
+
let group = new Group(this, {});
|
|
539
501
|
return group;
|
|
540
502
|
}
|
|
541
503
|
/**
|
|
@@ -547,31 +509,36 @@ class Book {
|
|
|
547
509
|
*/
|
|
548
510
|
getAccount(idOrName) {
|
|
549
511
|
return __awaiter(this, void 0, void 0, function* () {
|
|
550
|
-
if (idOrName
|
|
551
|
-
return
|
|
512
|
+
if (!idOrName) {
|
|
513
|
+
return undefined;
|
|
552
514
|
}
|
|
553
515
|
idOrName = idOrName + '';
|
|
554
516
|
const accountPlain = yield AccountService.getAccount(this.getId(), idOrName);
|
|
555
517
|
if (!accountPlain) {
|
|
556
|
-
return
|
|
518
|
+
return undefined;
|
|
557
519
|
}
|
|
558
|
-
const account =
|
|
559
|
-
account.book = this;
|
|
520
|
+
const account = new Account(this, accountPlain);
|
|
560
521
|
return account;
|
|
561
522
|
});
|
|
562
523
|
}
|
|
563
524
|
/** @internal */
|
|
564
525
|
updateGroupCache(group) {
|
|
565
|
-
group.book = this;
|
|
566
526
|
if (this.idGroupMap) {
|
|
567
|
-
|
|
568
|
-
|
|
527
|
+
const id = group.getId();
|
|
528
|
+
if (id) {
|
|
529
|
+
this.idGroupMap.set(id, group);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (this.nameGroupMap) {
|
|
533
|
+
this.nameGroupMap.set(normalizeName(group.getName()), group);
|
|
569
534
|
}
|
|
570
535
|
}
|
|
571
536
|
removeGroupCache(group) {
|
|
572
537
|
if (this.idGroupMap) {
|
|
573
|
-
this.idGroupMap.delete(group.getId());
|
|
574
|
-
|
|
538
|
+
this.idGroupMap.delete(group.getId() || '');
|
|
539
|
+
}
|
|
540
|
+
if (this.nameGroupMap) {
|
|
541
|
+
this.nameGroupMap.delete(normalizeName(group.getName()));
|
|
575
542
|
}
|
|
576
543
|
}
|
|
577
544
|
/**
|
|
@@ -583,14 +550,14 @@ class Book {
|
|
|
583
550
|
*/
|
|
584
551
|
getGroup(idOrName) {
|
|
585
552
|
return __awaiter(this, void 0, void 0, function* () {
|
|
586
|
-
if (idOrName
|
|
587
|
-
return
|
|
553
|
+
if (!idOrName) {
|
|
554
|
+
return undefined;
|
|
588
555
|
}
|
|
589
556
|
idOrName = idOrName + '';
|
|
590
557
|
if (this.idGroupMap) {
|
|
591
558
|
let group = this.idGroupMap.get(idOrName);
|
|
592
|
-
if (!group) {
|
|
593
|
-
group = this.nameGroupMap.get(
|
|
559
|
+
if (!group && this.nameGroupMap) {
|
|
560
|
+
group = this.nameGroupMap.get(normalizeName(idOrName));
|
|
594
561
|
}
|
|
595
562
|
if (group) {
|
|
596
563
|
return group;
|
|
@@ -598,9 +565,9 @@ class Book {
|
|
|
598
565
|
}
|
|
599
566
|
const groupPlain = yield GroupService.getGroup(this.getId(), idOrName);
|
|
600
567
|
if (!groupPlain) {
|
|
601
|
-
return
|
|
568
|
+
return undefined;
|
|
602
569
|
}
|
|
603
|
-
let group =
|
|
570
|
+
let group = new Group(this, groupPlain);
|
|
604
571
|
this.updateGroupCache(group);
|
|
605
572
|
return group;
|
|
606
573
|
});
|
|
@@ -614,7 +581,7 @@ class Book {
|
|
|
614
581
|
return Array.from(this.idGroupMap.values());
|
|
615
582
|
}
|
|
616
583
|
let groups = yield GroupService.getGroups(this.getId());
|
|
617
|
-
let groupsObj =
|
|
584
|
+
let groupsObj = groups.map(group => new Group(this, group));
|
|
618
585
|
this.idGroupMap = new Map();
|
|
619
586
|
this.nameGroupMap = new Map();
|
|
620
587
|
for (var i = 0; i < groupsObj.length; i++) {
|
|
@@ -630,10 +597,7 @@ class Book {
|
|
|
630
597
|
getGroupsByAccount(accountIdOrName) {
|
|
631
598
|
return __awaiter(this, void 0, void 0, function* () {
|
|
632
599
|
let groups = yield GroupService.getGroupsByAccountId(this.getId(), accountIdOrName);
|
|
633
|
-
let groupsObj =
|
|
634
|
-
for (const group of groupsObj) {
|
|
635
|
-
group.book = this;
|
|
636
|
-
}
|
|
600
|
+
let groupsObj = groups.map(group => new Group(this, group));
|
|
637
601
|
return groupsObj;
|
|
638
602
|
});
|
|
639
603
|
}
|
|
@@ -660,7 +624,7 @@ class Book {
|
|
|
660
624
|
* ```
|
|
661
625
|
*/
|
|
662
626
|
getTransactions(query) {
|
|
663
|
-
return new
|
|
627
|
+
return new TransactionIterator(this, query);
|
|
664
628
|
}
|
|
665
629
|
/**
|
|
666
630
|
* Retrieve a transaction by id
|
|
@@ -669,10 +633,9 @@ class Book {
|
|
|
669
633
|
return __awaiter(this, void 0, void 0, function* () {
|
|
670
634
|
let wrapped = yield TransactionService.getTransaction(this.getId(), id);
|
|
671
635
|
if (!wrapped) {
|
|
672
|
-
return
|
|
636
|
+
return undefined;
|
|
673
637
|
}
|
|
674
|
-
let transaction =
|
|
675
|
-
this.configureTransaction_(transaction);
|
|
638
|
+
let transaction = new Transaction(this, wrapped);
|
|
676
639
|
return transaction;
|
|
677
640
|
});
|
|
678
641
|
}
|
|
@@ -689,8 +652,7 @@ class Book {
|
|
|
689
652
|
* ```
|
|
690
653
|
*/
|
|
691
654
|
newFile() {
|
|
692
|
-
let file =
|
|
693
|
-
file.book = this;
|
|
655
|
+
let file = new File(this, {});
|
|
694
656
|
return file;
|
|
695
657
|
}
|
|
696
658
|
/**
|
|
@@ -699,7 +661,7 @@ class Book {
|
|
|
699
661
|
getFile(id) {
|
|
700
662
|
return __awaiter(this, void 0, void 0, function* () {
|
|
701
663
|
let wrapped = yield FileService.getFile(this.getId(), id);
|
|
702
|
-
let file =
|
|
664
|
+
let file = new File(this, wrapped);
|
|
703
665
|
return file;
|
|
704
666
|
});
|
|
705
667
|
}
|
|
@@ -713,5 +675,4 @@ class Book {
|
|
|
713
675
|
});
|
|
714
676
|
}
|
|
715
677
|
}
|
|
716
|
-
exports.Book = Book;
|
|
717
678
|
//# sourceMappingURL=Book.js.map
|
package/lib/model/Collection.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Collection = void 0;
|
|
4
|
-
const Book_1 = require("./Book");
|
|
1
|
+
import { Book } from "./Book.js";
|
|
5
2
|
/**
|
|
6
3
|
* This class defines a Collection of [[Books]].
|
|
7
4
|
*
|
|
8
5
|
* @public
|
|
9
6
|
*/
|
|
10
|
-
class Collection {
|
|
7
|
+
export class Collection {
|
|
11
8
|
/** @internal */
|
|
12
|
-
constructor(
|
|
13
|
-
this.wrapped =
|
|
9
|
+
constructor(json) {
|
|
10
|
+
this.wrapped = json || {};
|
|
14
11
|
}
|
|
15
12
|
/**
|
|
16
13
|
* @returns The id of this Collection
|
|
@@ -33,11 +30,10 @@ class Collection {
|
|
|
33
30
|
return books;
|
|
34
31
|
}
|
|
35
32
|
for (const bookPayload of this.wrapped.books) {
|
|
36
|
-
let book = new
|
|
33
|
+
let book = new Book(bookPayload);
|
|
37
34
|
books.push(book);
|
|
38
35
|
}
|
|
39
36
|
return books;
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
exports.Collection = Collection;
|
|
43
39
|
//# sourceMappingURL=Collection.js.map
|
package/lib/model/Config.js
CHANGED
package/lib/model/Connection.js
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,16 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
8
|
});
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const ConnectionService = __importStar(require("../service/connection-service"));
|
|
37
|
-
const Integration_1 = require("./Integration");
|
|
10
|
+
import * as ConnectionService from '../service/connection-service.js';
|
|
11
|
+
import { Integration } from './Integration.js';
|
|
38
12
|
/**
|
|
39
13
|
* This class defines a Connection from an [[User]] to an external service.
|
|
40
14
|
*
|
|
41
15
|
* @public
|
|
42
16
|
*/
|
|
43
|
-
class Connection {
|
|
17
|
+
export class Connection {
|
|
44
18
|
constructor(json) {
|
|
45
19
|
this.wrapped = json || {};
|
|
46
20
|
}
|
|
@@ -178,7 +152,7 @@ class Connection {
|
|
|
178
152
|
return value;
|
|
179
153
|
}
|
|
180
154
|
}
|
|
181
|
-
return
|
|
155
|
+
return undefined;
|
|
182
156
|
}
|
|
183
157
|
/**
|
|
184
158
|
* Sets a custom property in the Connection.
|
|
@@ -195,6 +169,9 @@ class Connection {
|
|
|
195
169
|
if (this.wrapped.properties == null) {
|
|
196
170
|
this.wrapped.properties = {};
|
|
197
171
|
}
|
|
172
|
+
if (!value) {
|
|
173
|
+
value = '';
|
|
174
|
+
}
|
|
198
175
|
this.wrapped.properties[key] = value;
|
|
199
176
|
return this;
|
|
200
177
|
}
|
|
@@ -241,7 +218,7 @@ class Connection {
|
|
|
241
218
|
getIntegrations() {
|
|
242
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
243
220
|
const integrationsPlain = yield ConnectionService.listIntegrations(this.getId());
|
|
244
|
-
const integrations = integrationsPlain.map(i => new
|
|
221
|
+
const integrations = integrationsPlain.map(i => new Integration(i));
|
|
245
222
|
return integrations;
|
|
246
223
|
});
|
|
247
224
|
}
|
|
@@ -257,5 +234,4 @@ class Connection {
|
|
|
257
234
|
});
|
|
258
235
|
}
|
|
259
236
|
}
|
|
260
|
-
exports.Connection = Connection;
|
|
261
237
|
//# sourceMappingURL=Connection.js.map
|
package/lib/model/Enums.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
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
1
|
/**
|
|
5
2
|
* The Periodicity of the query. It may depend on the level of granularity you write the range params.
|
|
6
3
|
*
|
|
7
4
|
* @public
|
|
8
5
|
*/
|
|
9
|
-
var Periodicity;
|
|
6
|
+
export var Periodicity;
|
|
10
7
|
(function (Periodicity) {
|
|
11
8
|
/**
|
|
12
9
|
* Example: after:25/01/1983, before:04/03/2013, after:$d-30, before:$d, after:$d-15/$m
|
|
@@ -20,13 +17,13 @@ var Periodicity;
|
|
|
20
17
|
* Example: on:2013, after:2013, $y
|
|
21
18
|
*/
|
|
22
19
|
Periodicity["YEARLY"] = "YEARLY";
|
|
23
|
-
})(Periodicity || (
|
|
20
|
+
})(Periodicity || (Periodicity = {}));
|
|
24
21
|
/**
|
|
25
22
|
* Decimal separator of numbers on book
|
|
26
23
|
*
|
|
27
24
|
* @public
|
|
28
25
|
*/
|
|
29
|
-
var DecimalSeparator;
|
|
26
|
+
export var DecimalSeparator;
|
|
30
27
|
(function (DecimalSeparator) {
|
|
31
28
|
/**
|
|
32
29
|
* ,
|
|
@@ -36,7 +33,7 @@ var DecimalSeparator;
|
|
|
36
33
|
* .
|
|
37
34
|
*/
|
|
38
35
|
DecimalSeparator["DOT"] = "DOT";
|
|
39
|
-
})(DecimalSeparator || (
|
|
36
|
+
})(DecimalSeparator || (DecimalSeparator = {}));
|
|
40
37
|
/**
|
|
41
38
|
* Enum representing permissions of user in the Book
|
|
42
39
|
*
|
|
@@ -44,7 +41,7 @@ var DecimalSeparator;
|
|
|
44
41
|
*
|
|
45
42
|
* @public
|
|
46
43
|
*/
|
|
47
|
-
var Permission;
|
|
44
|
+
export var Permission;
|
|
48
45
|
(function (Permission) {
|
|
49
46
|
/**
|
|
50
47
|
* No permission
|
|
@@ -70,13 +67,13 @@ var Permission;
|
|
|
70
67
|
* Manage everything, including book visibility and deletion. Only one owner per book.
|
|
71
68
|
*/
|
|
72
69
|
Permission["OWNER"] = "OWNER";
|
|
73
|
-
})(Permission || (
|
|
70
|
+
})(Permission || (Permission = {}));
|
|
74
71
|
/**
|
|
75
72
|
* Enum that represents account types.
|
|
76
73
|
*
|
|
77
74
|
* @public
|
|
78
75
|
*/
|
|
79
|
-
var AccountType;
|
|
76
|
+
export var AccountType;
|
|
80
77
|
(function (AccountType) {
|
|
81
78
|
/**
|
|
82
79
|
* Asset account type
|
|
@@ -94,13 +91,13 @@ var AccountType;
|
|
|
94
91
|
* Outgoing account type
|
|
95
92
|
*/
|
|
96
93
|
AccountType["OUTGOING"] = "OUTGOING";
|
|
97
|
-
})(AccountType || (
|
|
94
|
+
})(AccountType || (AccountType = {}));
|
|
98
95
|
/**
|
|
99
96
|
* Enum that represents a period slice.
|
|
100
97
|
*
|
|
101
98
|
* @public
|
|
102
99
|
*/
|
|
103
|
-
var Period;
|
|
100
|
+
export var Period;
|
|
104
101
|
(function (Period) {
|
|
105
102
|
/**
|
|
106
103
|
* Monthly period
|
|
@@ -114,13 +111,13 @@ var Period;
|
|
|
114
111
|
* Yearly period
|
|
115
112
|
*/
|
|
116
113
|
Period["YEAR"] = "YEAR";
|
|
117
|
-
})(Period || (
|
|
114
|
+
})(Period || (Period = {}));
|
|
118
115
|
/**
|
|
119
116
|
* Enum that represents a Month.
|
|
120
117
|
*
|
|
121
118
|
* @public
|
|
122
119
|
*/
|
|
123
|
-
var Month;
|
|
120
|
+
export var Month;
|
|
124
121
|
(function (Month) {
|
|
125
122
|
Month["JANUARY"] = "JANUARY";
|
|
126
123
|
Month["FEBRUARY"] = "FEBRUARY";
|
|
@@ -134,5 +131,5 @@ var Month;
|
|
|
134
131
|
Month["OCTOBER"] = "OCTOBER";
|
|
135
132
|
Month["NOVEMBER"] = "NOVEMBER";
|
|
136
133
|
Month["DECEMBER"] = "DECEMBER";
|
|
137
|
-
})(Month || (
|
|
134
|
+
})(Month || (Month = {}));
|
|
138
135
|
//# sourceMappingURL=Enums.js.map
|