bkper 3.0.0 → 3.1.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 +124 -0
- package/bun.lockb +0 -0
- package/package.json +8 -4
- package/src/auth/local-auth-service.ts +8 -2
- package/src/cli.ts +5 -9
- package/src/index.ts +11 -0
- package/tsconfig.json +4 -2
package/README.md
CHANGED
|
@@ -52,6 +52,130 @@ You can add a ```.env``` file at the root of your project with those variables a
|
|
|
52
52
|
|
|
53
53
|
> WARNING: Never upload variables to the source code repository.
|
|
54
54
|
|
|
55
|
+
|
|
56
|
+
### ```./bkperapp.json``` Reference
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
|
|
61
|
+
/* App basic configuration */
|
|
62
|
+
"id": "The App agent id. It can NOT be changed after the App created.",
|
|
63
|
+
"name": "The name of the App or Bot.",
|
|
64
|
+
"logoUrl": "Set your logo url from public host. Best fit 200x200 px. Use https://",
|
|
65
|
+
|
|
66
|
+
/* Context menu configuration */
|
|
67
|
+
"menuUrl": "The menu url to open in the popup window. See reference bellow.",
|
|
68
|
+
"menuUrlDev": "The menu url to open in the popup window, when opened by the developer user.",
|
|
69
|
+
"menuText": "The context menu call to action.",
|
|
70
|
+
"menuPopupWidth": "500 //width in pixels. Default to 80% of screen width.",
|
|
71
|
+
"menuPopupHeight": "300 //height in pixels. Default to 90% of screen height.",
|
|
72
|
+
|
|
73
|
+
/* Bot events configuration */
|
|
74
|
+
"events": [
|
|
75
|
+
"TRANSACTION_POSTED",
|
|
76
|
+
"TRANSACTION_CHECKED",
|
|
77
|
+
"TRANSACTION_UNCHECKED",
|
|
78
|
+
"TRANSACTION_UPDATED",
|
|
79
|
+
"TRANSACTION_DELETED",
|
|
80
|
+
"TRANSACTION_RESTORED",
|
|
81
|
+
"ACCOUNT_CREATED",
|
|
82
|
+
"ACCOUNT_UPDATED",
|
|
83
|
+
"ACCOUNT_DELETED",
|
|
84
|
+
"GROUP_CREATED",
|
|
85
|
+
"GROUP_UPDATED",
|
|
86
|
+
"GROUP_DELETED",
|
|
87
|
+
"FILE_CREATED",
|
|
88
|
+
"BOOK_UPDATED"
|
|
89
|
+
],
|
|
90
|
+
|
|
91
|
+
"filePatterns": [
|
|
92
|
+
"The file patterns the Bot is capable of process. It accepts wildcard. E.g.",
|
|
93
|
+
"radiusbank*.ofx",
|
|
94
|
+
"-*.qif"
|
|
95
|
+
],
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
/* Bot configuration only when additional scopes, other than email, is needed */
|
|
99
|
+
/* If not specified, a default valid token with the email scope is sent in the http header */
|
|
100
|
+
"clientId": "The Client ID from GCP project Web Application OAuth Credential",
|
|
101
|
+
"scopes": [
|
|
102
|
+
"The Google OAuth scopes used. E.g.",
|
|
103
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
|
104
|
+
"https://www.googleapis.com/auth/script.external_request"
|
|
105
|
+
],
|
|
106
|
+
|
|
107
|
+
/* Google Apps Script bot configuration */
|
|
108
|
+
"scriptId": "The Google Apps Script ID",
|
|
109
|
+
"deploymentId": "The Google Apps Script API Deployment ID",
|
|
110
|
+
|
|
111
|
+
/* Webhook bot configuration */
|
|
112
|
+
"webhookUrl": "The production webhook url",
|
|
113
|
+
"webhookUrlDev": "The development webhook url",
|
|
114
|
+
|
|
115
|
+
/* Schema to provide autocompletion */
|
|
116
|
+
"propertiesSchema": {
|
|
117
|
+
"book": {
|
|
118
|
+
"keys": [
|
|
119
|
+
"key1",
|
|
120
|
+
"key2"
|
|
121
|
+
],
|
|
122
|
+
"values": [
|
|
123
|
+
"value2",
|
|
124
|
+
"value2"
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
"group": {
|
|
128
|
+
"keys": [
|
|
129
|
+
"key1",
|
|
130
|
+
"key2"
|
|
131
|
+
],
|
|
132
|
+
"values": [
|
|
133
|
+
"value2",
|
|
134
|
+
"value2"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"account": {
|
|
138
|
+
"keys": [
|
|
139
|
+
"key1",
|
|
140
|
+
"key2"
|
|
141
|
+
],
|
|
142
|
+
"values": [
|
|
143
|
+
"value2",
|
|
144
|
+
"value2"
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
"transaction": {
|
|
148
|
+
"keys": [
|
|
149
|
+
"key1",
|
|
150
|
+
"key2"
|
|
151
|
+
],
|
|
152
|
+
"values": [
|
|
153
|
+
"value2",
|
|
154
|
+
"value2"
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Accepted expressions in menuUrl property:
|
|
163
|
+
- ```${book.id}``` - the current book id
|
|
164
|
+
- ```${book.properties.xxxxx}``` - any property value from the current book
|
|
165
|
+
- ```${transactions.query}``` - the current query being executed on transactions list
|
|
166
|
+
- ```${transactions.ids}``` - the ids of selected transactions, splitted by comma
|
|
167
|
+
- ```${account.id}``` - the current account being filterd
|
|
168
|
+
- ```${account.properties.xxxxx}``` - any property value from the current account being filtered
|
|
169
|
+
- ```${group.id}``` - the current group being filterd
|
|
170
|
+
- ```${group.properties.xxxxx}``` - any property value from the current group being filtered
|
|
171
|
+
|
|
172
|
+
#### Example:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
"menuUrl": "https://app.bkper.com/b/#transactions:bookId=${book.id}"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
|
|
55
179
|
## Documentation
|
|
56
180
|
|
|
57
181
|
- [Developer Docs](https://bkper.com/docs)
|
package/bun.lockb
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Node.js command line client for Bkper",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bkper": "./lib/cli.js"
|
|
@@ -10,13 +10,17 @@
|
|
|
10
10
|
"author": "mael <mael@bkper.com>",
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"private": false,
|
|
13
|
+
"main": "./lib/index.js",
|
|
14
|
+
"module": "./lib/index.js",
|
|
15
|
+
"types": "./lib/index.d.ts",
|
|
16
|
+
"type": "module",
|
|
13
17
|
"scripts": {
|
|
14
18
|
"clean": "rm -rf ./lib & rm -rf ./node_modules & wait",
|
|
19
|
+
"prebuild": "bun install",
|
|
15
20
|
"build": "run-s build:*",
|
|
16
21
|
"build:clean": "gts clean",
|
|
17
22
|
"build:compile": "tsc",
|
|
18
|
-
"
|
|
19
|
-
"build:clean-dist": "rimraf dist",
|
|
23
|
+
"prewatch": "bun run build",
|
|
20
24
|
"watch": "tsc -w",
|
|
21
25
|
"patch": "yarn version --patch",
|
|
22
26
|
"minor": "yarn version --minor",
|
|
@@ -26,7 +30,7 @@
|
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
32
|
"@google-cloud/local-auth": "^3.0.1",
|
|
29
|
-
"bkper-js": "^1.
|
|
33
|
+
"bkper-js": "^1.1.0",
|
|
30
34
|
"commander": "^6.2.1",
|
|
31
35
|
"dotenv": "^8.2.0",
|
|
32
36
|
"google-auth-library": "^9.14.0"
|
|
@@ -2,6 +2,13 @@ import {authenticate} from '@google-cloud/local-auth';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { Credentials, OAuth2Client } from "google-auth-library";
|
|
4
4
|
import os from 'os';
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
|
|
11
|
+
const __dirname = path.dirname(__filename); // get the name of the directory
|
|
5
12
|
|
|
6
13
|
const keys = require(`${__dirname}/keys.json`);
|
|
7
14
|
|
|
@@ -56,14 +63,13 @@ export async function getOAuthToken(): Promise<string> {
|
|
|
56
63
|
localAuth.on('tokens', (tokens) => {
|
|
57
64
|
if (tokens.refresh_token) {
|
|
58
65
|
// store the refresh_token in my database!
|
|
59
|
-
console.log(tokens.refresh_token);
|
|
60
66
|
storeCredentials(tokens)
|
|
61
67
|
}
|
|
62
68
|
});
|
|
63
69
|
|
|
64
70
|
let token = await localAuth.getAccessToken();
|
|
65
71
|
|
|
66
|
-
return token.token;
|
|
72
|
+
return token.token || '';
|
|
67
73
|
|
|
68
74
|
}
|
|
69
75
|
|
package/src/cli.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import program from 'commander';
|
|
4
|
-
import { getOAuthToken, login, logout } from './auth/local-auth-service';
|
|
5
3
|
import { App, Bkper } from 'bkper-js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import program from 'commander';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import { login, logout } from './auth/local-auth-service.js';
|
|
7
|
+
import { getBkperLocalConfig } from './index.js';
|
|
9
8
|
|
|
10
9
|
program
|
|
11
10
|
.command('login')
|
|
@@ -29,10 +28,7 @@ program
|
|
|
29
28
|
.action(async (options) => {
|
|
30
29
|
|
|
31
30
|
try {
|
|
32
|
-
Bkper.setConfig(
|
|
33
|
-
apiKeyProvider: async () => process.env.BKPER_API_KEY,
|
|
34
|
-
oauthTokenProvider: () => getOAuthToken()
|
|
35
|
-
})
|
|
31
|
+
Bkper.setConfig(getBkperLocalConfig())
|
|
36
32
|
const json: bkper.App = JSON.parse(fs.readFileSync('./bkperapp.json', 'utf8'));
|
|
37
33
|
let app = new App(json)
|
|
38
34
|
.setReadme(fs.readFileSync('./README.md', 'utf8'))
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Config } from 'bkper-js';
|
|
2
|
+
import { getOAuthToken } from './auth/local-auth-service.js';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
dotenv.config()
|
|
5
|
+
|
|
6
|
+
export function getBkperLocalConfig(): Config {
|
|
7
|
+
return {
|
|
8
|
+
apiKeyProvider: async () => process.env.BKPER_API_KEY || '',
|
|
9
|
+
oauthTokenProvider: () => getOAuthToken()
|
|
10
|
+
}
|
|
11
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"rootDir": "src",
|
|
5
5
|
"outDir": "lib",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "Node",
|
|
8
|
+
"resolveJsonModule": true,
|
|
6
9
|
"typeRoots" : ["node_modules/@bkper", "node_modules/@types" ],
|
|
7
|
-
"strict":
|
|
10
|
+
"strict": true,
|
|
8
11
|
"esModuleInterop": true,
|
|
9
12
|
"target": "es2015",
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
13
|
"declaration": true,
|
|
12
14
|
"sourceMap": true,
|
|
13
15
|
"declarationMap": true
|