bkper-js 2.12.0 → 2.12.2

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
@@ -3604,6 +3604,12 @@ export declare class Transaction extends Resource<bkper.Transaction> {
3604
3604
  * @returns The date the transaction was created, formatted according to the date pattern of the [[Book]]
3605
3605
  */
3606
3606
  getCreatedAtFormatted(): string;
3607
+ /**
3608
+ * Gets the username of the user who created the transaction.
3609
+ *
3610
+ * @returns The username of the user who created the transaction
3611
+ */
3612
+ getCreatedBy(): string | undefined;
3607
3613
  /**
3608
3614
  * Gets the date when the transaction was last updated.
3609
3615
  *
@@ -155,7 +155,14 @@ export class Transaction extends Resource {
155
155
  * @returns All #hashtags used on the transaction
156
156
  */
157
157
  getTags() {
158
- return this.payload.tags || [];
158
+ if (this.payload.tags && this.payload.tags.length > 0) {
159
+ return this.payload.tags;
160
+ }
161
+ const description = this.getDescription();
162
+ if (description && description.includes('#')) {
163
+ return Utils.extractTagsFromText(description);
164
+ }
165
+ return [];
159
166
  }
160
167
  /**
161
168
  * Gets all URLs associated with the transaction.
@@ -710,6 +717,14 @@ export class Transaction extends Resource {
710
717
  getCreatedAtFormatted() {
711
718
  return Utils.formatDate(this.getCreatedAt(), this.book.getDatePattern() + " HH:mm:ss", this.book.getTimeZone());
712
719
  }
720
+ /**
721
+ * Gets the username of the user who created the transaction.
722
+ *
723
+ * @returns The username of the user who created the transaction
724
+ */
725
+ getCreatedBy() {
726
+ return this.payload.createdBy;
727
+ }
713
728
  /**
714
729
  * Gets the date when the transaction was last updated.
715
730
  *
package/lib/utils.js CHANGED
@@ -20,6 +20,20 @@ export function repeatString(text, times) {
20
20
  return text + repeatString(text, times - 1);
21
21
  ;
22
22
  }
23
+ export function extractTagsFromText(text) {
24
+ if (!text || typeof text !== 'string') {
25
+ return [];
26
+ }
27
+ const tagRegex = /#([a-zA-Z0-9_]+)/g;
28
+ const tagsSet = new Set();
29
+ let match;
30
+ while ((match = tagRegex.exec(text)) !== null) {
31
+ if (match[1]) {
32
+ tagsSet.add(match[1]);
33
+ }
34
+ }
35
+ return Array.from(tagsSet);
36
+ }
23
37
  //SAME AS bkper-app
24
38
  var diacriticsMap_ = null;
25
39
  export function round(number, fractionDigits) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.12.0",
3
+ "version": "2.12.2",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -15,8 +15,9 @@
15
15
  "license": "Apache-2.0",
16
16
  "private": false,
17
17
  "scripts": {
18
- "test": "env TS_NODE_COMPILER_OPTIONS='{\"rootDir\": \".\" }' mocha -r ts-node/register 'test/**/*.ts'",
18
+ "test": "env TS_NODE_COMPILER_OPTIONS='{\"rootDir\": \".\", \"lib\": [\"es2020\", \"dom\"] }' mocha -r ts-node/register 'test/**/*.ts'",
19
19
  "clean": "rm -rf ./lib & rm -rf ./node_modules & wait",
20
+ "prebuild": "bun install",
20
21
  "build": "run-s build:*",
21
22
  "build:clean": "gts clean",
22
23
  "build:compile": "tsc",