bkper-js 1.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.
- package/LICENSE +201 -0
- package/README.md +27 -0
- package/lib/index.d.ts +1804 -0
- package/lib/index.js +42 -0
- package/lib/model/Account.js +385 -0
- package/lib/model/Amount.js +295 -0
- package/lib/model/App.js +114 -0
- package/lib/model/Bkper.js +105 -0
- package/lib/model/Book.js +717 -0
- package/lib/model/Collection.js +43 -0
- package/lib/model/Config.js +3 -0
- package/lib/model/Connection.js +261 -0
- package/lib/model/Enums.js +138 -0
- package/lib/model/File.js +128 -0
- package/lib/model/Group.js +248 -0
- package/lib/model/Integration.js +112 -0
- package/lib/model/Transaction.js +719 -0
- package/lib/model/TransactionIterator.js +154 -0
- package/lib/model/TransactionPage.js +97 -0
- package/lib/model/User.js +97 -0
- package/lib/service/account-service.js +42 -0
- package/lib/service/app-service.js +34 -0
- package/lib/service/balances-service.js +20 -0
- package/lib/service/book-service.js +36 -0
- package/lib/service/connection-service.js +71 -0
- package/lib/service/file-service.js +27 -0
- package/lib/service/group-service.js +71 -0
- package/lib/service/http-api-request.js +165 -0
- package/lib/service/integration-service.js +52 -0
- package/lib/service/transaction-service.js +114 -0
- package/lib/service/user-service.js +20 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/utils.js +341 -0
- package/package.json +58 -0
|
@@ -0,0 +1,43 @@
|
|
|
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
|
|
@@ -0,0 +1,261 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.Connection = void 0;
|
|
36
|
+
const ConnectionService = __importStar(require("../service/connection-service"));
|
|
37
|
+
const Integration_1 = require("./Integration");
|
|
38
|
+
/**
|
|
39
|
+
* This class defines a Connection from an [[User]] to an external service.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
class Connection {
|
|
44
|
+
constructor(json) {
|
|
45
|
+
this.wrapped = json || {};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Gets the wrapped plain json object of the Connection.
|
|
49
|
+
*
|
|
50
|
+
* @returns The Connection wrapped plain json object
|
|
51
|
+
*/
|
|
52
|
+
json() {
|
|
53
|
+
return this.wrapped;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the id of the Connection.
|
|
57
|
+
*
|
|
58
|
+
* @returns The Connection's id
|
|
59
|
+
*/
|
|
60
|
+
getId() {
|
|
61
|
+
return this.wrapped.id;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the agentId of the Connection.
|
|
65
|
+
*
|
|
66
|
+
* @returns The Connection's agentId
|
|
67
|
+
*/
|
|
68
|
+
getAgentId() {
|
|
69
|
+
return this.wrapped.agentId;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Sets the Connection agentId.
|
|
73
|
+
*
|
|
74
|
+
* @param agentId - The Connection agentId
|
|
75
|
+
*
|
|
76
|
+
* @returns The Connection, for chainning
|
|
77
|
+
*/
|
|
78
|
+
setAgentId(agentId) {
|
|
79
|
+
this.wrapped.agentId = agentId;
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Gets the name of the Connection.
|
|
84
|
+
*
|
|
85
|
+
* @returns The Connection name
|
|
86
|
+
*/
|
|
87
|
+
getName() {
|
|
88
|
+
return this.wrapped.name;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Gets the email of the owner of the Connection.
|
|
92
|
+
*
|
|
93
|
+
* @returns The Connection owner's email
|
|
94
|
+
*/
|
|
95
|
+
getEmail() {
|
|
96
|
+
return this.wrapped.email;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Sets the name of the Connection.
|
|
100
|
+
*
|
|
101
|
+
* @param name - The name of the Connection
|
|
102
|
+
*
|
|
103
|
+
* @returns The Connection, for chainning
|
|
104
|
+
*/
|
|
105
|
+
setName(name) {
|
|
106
|
+
this.wrapped.name = name;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Sets the universal unique identifier of the Connection.
|
|
111
|
+
*
|
|
112
|
+
* @param uuid - The universal unique identifier of the Connection
|
|
113
|
+
*
|
|
114
|
+
* @returns The Connection, for chainning
|
|
115
|
+
*/
|
|
116
|
+
setUUID(uuid) {
|
|
117
|
+
this.wrapped.uuid = uuid;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Gets the universal unique identifier of this Connection.
|
|
122
|
+
*
|
|
123
|
+
* @returns The Connection's universal unique identifier name
|
|
124
|
+
*/
|
|
125
|
+
getUUID() {
|
|
126
|
+
return this.wrapped.uuid;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets the type of the Connection.
|
|
130
|
+
*
|
|
131
|
+
* @returns The Connection type
|
|
132
|
+
*/
|
|
133
|
+
getType() {
|
|
134
|
+
return this.wrapped.type;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Sets the Connection type.
|
|
138
|
+
*
|
|
139
|
+
* @param type - The Connection type
|
|
140
|
+
*
|
|
141
|
+
* @returns The Connection, for chainning
|
|
142
|
+
*/
|
|
143
|
+
setType(type) {
|
|
144
|
+
this.wrapped.type = type;
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Gets the custom properties stored in the Connection
|
|
149
|
+
*
|
|
150
|
+
* @returns Object with key/value pair properties
|
|
151
|
+
*/
|
|
152
|
+
getProperties() {
|
|
153
|
+
return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Sets the custom properties of the Connection.
|
|
157
|
+
*
|
|
158
|
+
* @param properties - Object with key/value pair properties
|
|
159
|
+
*
|
|
160
|
+
* @returns The Connection, for chainning
|
|
161
|
+
*/
|
|
162
|
+
setProperties(properties) {
|
|
163
|
+
this.wrapped.properties = Object.assign({}, properties);
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Gets the property value for given keys. First property found will be retrieved.
|
|
168
|
+
*
|
|
169
|
+
* @param keys - The property key
|
|
170
|
+
*
|
|
171
|
+
* @returns The retrieved property value
|
|
172
|
+
*/
|
|
173
|
+
getProperty(...keys) {
|
|
174
|
+
for (let index = 0; index < keys.length; index++) {
|
|
175
|
+
const key = keys[index];
|
|
176
|
+
let value = this.wrapped.properties != null ? this.wrapped.properties[key] : null;
|
|
177
|
+
if (value != null && value.trim() != '') {
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Sets a custom property in the Connection.
|
|
185
|
+
*
|
|
186
|
+
* @param key - The property key
|
|
187
|
+
* @param value - The property value
|
|
188
|
+
*
|
|
189
|
+
* @returns The Connection, for chaining
|
|
190
|
+
*/
|
|
191
|
+
setProperty(key, value) {
|
|
192
|
+
if (key == null || key.trim() == '') {
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
if (this.wrapped.properties == null) {
|
|
196
|
+
this.wrapped.properties = {};
|
|
197
|
+
}
|
|
198
|
+
this.wrapped.properties[key] = value;
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Deletes a custom property stored in the Connection.
|
|
203
|
+
*
|
|
204
|
+
* @param key - The property key
|
|
205
|
+
*
|
|
206
|
+
* @returns The Connection, for chainning
|
|
207
|
+
*/
|
|
208
|
+
deleteProperty(key) {
|
|
209
|
+
this.setProperty(key, null);
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Cleans any token property stored in the Connection.
|
|
214
|
+
*/
|
|
215
|
+
clearTokenProperties() {
|
|
216
|
+
this.getPropertyKeys().filter(key => key.includes("token")).forEach(key => this.deleteProperty(key));
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Gets the custom properties keys stored in the Connection.
|
|
220
|
+
*
|
|
221
|
+
* @returns The retrieved property keys
|
|
222
|
+
*/
|
|
223
|
+
getPropertyKeys() {
|
|
224
|
+
let properties = this.getProperties();
|
|
225
|
+
let propertyKeys = [];
|
|
226
|
+
if (properties) {
|
|
227
|
+
for (var key in properties) {
|
|
228
|
+
if (Object.prototype.hasOwnProperty.call(properties, key)) {
|
|
229
|
+
propertyKeys.push(key);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
propertyKeys = propertyKeys.sort();
|
|
234
|
+
return propertyKeys;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Gets the existing [[Integrations]] on the Connection.
|
|
238
|
+
*
|
|
239
|
+
* @returns The existing Integration objects
|
|
240
|
+
*/
|
|
241
|
+
getIntegrations() {
|
|
242
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
+
const integrationsPlain = yield ConnectionService.listIntegrations(this.getId());
|
|
244
|
+
const integrations = integrationsPlain.map(i => new Integration_1.Integration(i));
|
|
245
|
+
return integrations;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Performs create new Connection.
|
|
250
|
+
*
|
|
251
|
+
* @returns The Connection, for chaining
|
|
252
|
+
*/
|
|
253
|
+
create() {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
this.wrapped = yield ConnectionService.createConnection(this.wrapped);
|
|
256
|
+
return this;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.Connection = Connection;
|
|
261
|
+
//# sourceMappingURL=Connection.js.map
|
|
@@ -0,0 +1,138 @@
|
|
|
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 = 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 = 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 = 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 = 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 = 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 = Month = {}));
|
|
138
|
+
//# sourceMappingURL=Enums.js.map
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.File = void 0;
|
|
36
|
+
const FileService = __importStar(require("../service/file-service"));
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* This class defines a File uploaded to a [[Book]].
|
|
40
|
+
*
|
|
41
|
+
* A File can be attached to a [[Transaction]] or used to import data.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
class File {
|
|
46
|
+
/**
|
|
47
|
+
* Gets the File id
|
|
48
|
+
*/
|
|
49
|
+
getId() {
|
|
50
|
+
return this.wrapped.id;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the File name
|
|
54
|
+
*/
|
|
55
|
+
getName() {
|
|
56
|
+
return this.wrapped.name;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* Sets the name of the File.
|
|
61
|
+
*
|
|
62
|
+
* @returns This File, for chainning.
|
|
63
|
+
*/
|
|
64
|
+
setName(name) {
|
|
65
|
+
this.wrapped.name = name;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the File content type
|
|
70
|
+
*/
|
|
71
|
+
getContentType() {
|
|
72
|
+
return this.wrapped.contentType;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* Sets the File content type.
|
|
77
|
+
*
|
|
78
|
+
* @returns This File, for chainning.
|
|
79
|
+
*/
|
|
80
|
+
setContentType(contentType) {
|
|
81
|
+
this.wrapped.contentType = contentType;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets the file content Base64 encoded
|
|
86
|
+
*/
|
|
87
|
+
getContent() {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
if (this.getId() != null && (this.wrapped == null || this.wrapped.content == null)) {
|
|
90
|
+
this.wrapped = yield FileService.getFile(this.book.getId(), this.getId());
|
|
91
|
+
}
|
|
92
|
+
return this.wrapped.content;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* Sets the File content Base64 encoded.
|
|
98
|
+
*
|
|
99
|
+
* @returns This File, for chainning.
|
|
100
|
+
*/
|
|
101
|
+
setContent(content) {
|
|
102
|
+
this.wrapped.content = content;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Gets the file serving url for accessing via browser
|
|
107
|
+
*/
|
|
108
|
+
getUrl() {
|
|
109
|
+
return this.wrapped.url;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Gets the file size in bytes
|
|
113
|
+
*/
|
|
114
|
+
getSize() {
|
|
115
|
+
return this.wrapped.size;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Perform create new File.
|
|
119
|
+
*/
|
|
120
|
+
create() {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
this.wrapped = yield FileService.createFile(this.book.getId(), this.wrapped);
|
|
123
|
+
return this;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.File = File;
|
|
128
|
+
//# sourceMappingURL=File.js.map
|