bkper-js 2.16.1 → 2.17.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/lib/index.d.ts CHANGED
@@ -2514,6 +2514,12 @@ export declare class File extends ResourceProperty<bkper.File> {
2514
2514
  * @returns The created File object
2515
2515
  */
2516
2516
  create(): Promise<File>;
2517
+ /**
2518
+ * Perform update File, applying pending changes.
2519
+ *
2520
+ * @returns The updated File object
2521
+ */
2522
+ update(): Promise<File>;
2517
2523
  }
2518
2524
 
2519
2525
  /**
@@ -125,7 +125,7 @@ export class Bkper {
125
125
  getApps() {
126
126
  return __awaiter(this, void 0, void 0, function* () {
127
127
  let apps = yield AppService.getApps(this.config);
128
- return apps.map((app) => new App(app));
128
+ return apps.map((app) => new App(app, this.config));
129
129
  });
130
130
  }
131
131
  /**
@@ -136,7 +136,7 @@ export class Bkper {
136
136
  getTemplates() {
137
137
  return __awaiter(this, void 0, void 0, function* () {
138
138
  let templates = yield TemplateService.getTemplates(this.config);
139
- return templates.map((template) => new Template(template));
139
+ return templates.map((template) => new Template(template, this.config));
140
140
  });
141
141
  }
142
142
  /**
package/lib/model/Book.js CHANGED
@@ -192,7 +192,7 @@ export class Book extends ResourceProperty {
192
192
  */
193
193
  getCollection() {
194
194
  if (this.payload.collection != null && this.collection == null) {
195
- this.collection = new Collection(this.payload.collection);
195
+ this.collection = new Collection(this.payload.collection, this.config);
196
196
  }
197
197
  return this.collection;
198
198
  }
@@ -612,7 +612,7 @@ export class Book extends ResourceProperty {
612
612
  return this.apps;
613
613
  }
614
614
  const appsPlain = yield BookService.getApps(this.getId(), this.getConfig());
615
- this.apps = appsPlain.map((a) => new App(a));
615
+ this.apps = appsPlain.map((a) => new App(a, this.config));
616
616
  return this.apps;
617
617
  });
618
618
  }
@@ -624,7 +624,7 @@ export class Book extends ResourceProperty {
624
624
  getIntegrations() {
625
625
  return __awaiter(this, void 0, void 0, function* () {
626
626
  const integrationsPlain = yield IntegrationService.listIntegrations(this.getId(), this.getConfig());
627
- const integrations = integrationsPlain.map((i) => new Integration(i));
627
+ const integrations = integrationsPlain.map((i) => new Integration(i, this.config));
628
628
  return integrations;
629
629
  });
630
630
  }
@@ -643,7 +643,7 @@ export class Book extends ResourceProperty {
643
643
  else {
644
644
  integration = yield IntegrationService.createIntegration(this.getId(), integration, this.getConfig());
645
645
  }
646
- return new Integration(integration);
646
+ return new Integration(integration, this.config);
647
647
  });
648
648
  }
649
649
  /**
@@ -661,7 +661,7 @@ export class Book extends ResourceProperty {
661
661
  else {
662
662
  integration = yield IntegrationService.updateIntegration(this.getId(), integration, this.getConfig());
663
663
  }
664
- return new Integration(integration);
664
+ return new Integration(integration, this.config);
665
665
  });
666
666
  }
667
667
  /**
@@ -1100,7 +1100,7 @@ export class Book extends ResourceProperty {
1100
1100
  copy(name, copyTransactions, fromDate) {
1101
1101
  return __awaiter(this, void 0, void 0, function* () {
1102
1102
  const copiedBookPayload = yield BookService.copyBook(this.getId(), name, copyTransactions, fromDate, this.getConfig());
1103
- return new Book(copiedBookPayload);
1103
+ return new Book(copiedBookPayload, this.config);
1104
1104
  });
1105
1105
  }
1106
1106
  /**
@@ -1188,7 +1188,7 @@ export class Book extends ResourceProperty {
1188
1188
  getBacklog() {
1189
1189
  return __awaiter(this, void 0, void 0, function* () {
1190
1190
  const backlogPayload = yield EventService.getBacklog(this, this.getConfig());
1191
- return new Backlog(backlogPayload);
1191
+ return new Backlog(backlogPayload, this.config);
1192
1192
  });
1193
1193
  }
1194
1194
  }
@@ -81,7 +81,7 @@ export class Collection extends Resource {
81
81
  return books;
82
82
  }
83
83
  for (const bookPayload of this.payload.books) {
84
- let book = new Book(bookPayload);
84
+ let book = new Book(bookPayload, this.config);
85
85
  books.push(book);
86
86
  }
87
87
  return books;
@@ -99,7 +99,7 @@ export class Collection extends Resource {
99
99
  if (collectionId && books.length > 0) {
100
100
  const bookList = { items: books.map((b) => b.json()) };
101
101
  let addedBooks = yield CollectionService.addBooksToCollection(collectionId, bookList, this.getConfig());
102
- return addedBooks.map((book) => new Book(book));
102
+ return addedBooks.map((book) => new Book(book, this.config));
103
103
  }
104
104
  return [];
105
105
  });
@@ -117,7 +117,7 @@ export class Collection extends Resource {
117
117
  if (collectionId && books.length > 0) {
118
118
  const bookList = { items: books.map((b) => b.json()) };
119
119
  let removedBooks = yield CollectionService.removeBooksFromCollection(collectionId, bookList, this.getConfig());
120
- return removedBooks.map((book) => new Book(book));
120
+ return removedBooks.map((book) => new Book(book, this.config));
121
121
  }
122
122
  return [];
123
123
  });
@@ -160,7 +160,7 @@ export class Collection extends Resource {
160
160
  remove() {
161
161
  return __awaiter(this, void 0, void 0, function* () {
162
162
  let books = yield CollectionService.deleteCollection(this.payload, this.getConfig());
163
- return books.map((book) => new Book(book));
163
+ return books.map((book) => new Book(book, this.config));
164
164
  });
165
165
  }
166
166
  }
@@ -153,7 +153,7 @@ export class Connection extends ResourceProperty {
153
153
  return [];
154
154
  }
155
155
  const integrationsPlain = yield ConnectionService.listIntegrations(id, this.getConfig());
156
- const integrations = integrationsPlain.map((i) => new Integration(i));
156
+ const integrations = integrationsPlain.map((i) => new Integration(i, this.config));
157
157
  return integrations;
158
158
  });
159
159
  }
@@ -45,7 +45,7 @@ export class Event {
45
45
  * @returns The user who performed the Event
46
46
  */
47
47
  getUser() {
48
- return this.payload.user ? new User(this.payload.user) : undefined;
48
+ return this.payload.user ? new User(this.payload.user, this.book.getConfig()) : undefined;
49
49
  }
50
50
  /**
51
51
  * Gets the Agent who performed the Event.
package/lib/model/File.js CHANGED
@@ -131,9 +131,18 @@ export class File extends ResourceProperty {
131
131
  */
132
132
  create() {
133
133
  return __awaiter(this, void 0, void 0, function* () {
134
- if (this.book) {
135
- this.payload = yield FileService.createFile(this.book.getId(), this.payload, this.getConfig());
136
- }
134
+ this.payload = yield FileService.createFile(this.book.getId(), this.payload, this.getConfig());
135
+ return this;
136
+ });
137
+ }
138
+ /**
139
+ * Perform update File, applying pending changes.
140
+ *
141
+ * @returns The updated File object
142
+ */
143
+ update() {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ this.payload = yield FileService.updateFile(this.book.getId(), this.payload, this.getConfig());
137
146
  return this;
138
147
  });
139
148
  }
package/lib/model/User.js CHANGED
@@ -133,7 +133,7 @@ export class User extends Resource {
133
133
  getConnections() {
134
134
  return __awaiter(this, void 0, void 0, function* () {
135
135
  const json = yield ConnectionService.listConnections(this.getConfig());
136
- return json.map((c) => new Connection(c));
136
+ return json.map((c) => new Connection(c, this.config));
137
137
  });
138
138
  }
139
139
  /**
@@ -146,7 +146,7 @@ export class User extends Resource {
146
146
  getConnection(id) {
147
147
  return __awaiter(this, void 0, void 0, function* () {
148
148
  const json = yield ConnectionService.getConnection(id, this.getConfig());
149
- return new Connection(json);
149
+ return new Connection(json, this.config);
150
150
  });
151
151
  }
152
152
  }
@@ -20,4 +20,10 @@ export function getFile(bookId, id, config) {
20
20
  return response.data;
21
21
  });
22
22
  }
23
+ export function updateFile(bookId, file, config) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ let response = yield new HttpBooksApiV5Request(`${bookId}/files`, config).setMethod('PUT').setPayload(file).fetch();
26
+ return response.data;
27
+ });
28
+ }
23
29
  //# sourceMappingURL=file-service.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.16.1",
3
+ "version": "2.17.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -35,7 +35,7 @@
35
35
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
36
36
  },
37
37
  "peerDependencies": {
38
- "@bkper/bkper-api-types": "^5.30.0"
38
+ "@bkper/bkper-api-types": "^5.32.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "big.js": "^6.0.3",