bkper 2.7.2 → 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.
Files changed (42) hide show
  1. package/README.md +132 -8
  2. package/bun.lockb +0 -0
  3. package/package.json +15 -34
  4. package/src/auth/keys.json +12 -0
  5. package/src/auth/local-auth-service.ts +79 -0
  6. package/src/cli.ts +53 -0
  7. package/src/index.ts +11 -0
  8. package/tsconfig.json +27 -0
  9. package/lib/auth/keys.json +0 -12
  10. package/lib/auth/local-auth-service.js +0 -80
  11. package/lib/cli.js +0 -64
  12. package/lib/index.d.ts +0 -1775
  13. package/lib/index.js +0 -42
  14. package/lib/model/Account.js +0 -381
  15. package/lib/model/Amount.js +0 -295
  16. package/lib/model/App.js +0 -95
  17. package/lib/model/Bkper.js +0 -101
  18. package/lib/model/Book.js +0 -713
  19. package/lib/model/Collection.js +0 -43
  20. package/lib/model/Config.js +0 -3
  21. package/lib/model/Connection.js +0 -257
  22. package/lib/model/Enums.js +0 -138
  23. package/lib/model/File.js +0 -124
  24. package/lib/model/Group.js +0 -244
  25. package/lib/model/Integration.js +0 -112
  26. package/lib/model/Transaction.js +0 -715
  27. package/lib/model/TransactionIterator.js +0 -154
  28. package/lib/model/TransactionPage.js +0 -93
  29. package/lib/model/User.js +0 -93
  30. package/lib/service/account-service.js +0 -43
  31. package/lib/service/app-service.js +0 -35
  32. package/lib/service/balances-service.js +0 -21
  33. package/lib/service/book-service.js +0 -37
  34. package/lib/service/connection-service.js +0 -72
  35. package/lib/service/file-service.js +0 -28
  36. package/lib/service/group-service.js +0 -72
  37. package/lib/service/http-api-request.js +0 -169
  38. package/lib/service/integration-service.js +0 -53
  39. package/lib/service/transaction-service.js +0 -115
  40. package/lib/service/user-service.js +0 -21
  41. package/lib/tsdoc-metadata.json +0 -11
  42. package/lib/utils.js +0 -341
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  [Bkper REST API]: https://bkper.com/docs/#rest-apis
2
2
 
3
- [![npm](https://img.shields.io/npm/v/bkper?color=%235889e4)](https://www.npmjs.com/package/bkper)
4
-
5
- Bkper Node.js client provides a simple and secure way to access the [Bkper REST API] on [Node.js](https://nodejs.dev/)
6
-
7
- It also provide a **command line** utility to create and update [Bkper Apps and Bots](https://bkper.com/docs/)
3
+ A **command line** utility to create and update [Bkper Apps and Bots](https://bkper.com/docs/)
8
4
 
9
5
  ## Instalation
10
6
 
11
7
  ### Add the package:
12
8
 
13
9
  ```
14
- npm i -S bkper
10
+ npm i bkper --save-dev
15
11
  ```
16
12
  or
17
13
  ```
18
- yarn add bkper
14
+ yarn add bkper --dev
15
+ ```
16
+ or
17
+ ```
18
+ bun add bkper --dev
19
19
  ```
20
20
 
21
21
  ## Commands
@@ -34,7 +34,7 @@ yarn bkper login
34
34
  ```
35
35
 
36
36
  ### Environment Variables
37
- The following environment variable is necessary in order to communicate with the Bkper REST API:
37
+ The following environment variable is necessary in order to communicate with the [Bkper REST API]:
38
38
 
39
39
  ```
40
40
  BKPER_API_KEY=XXXX
@@ -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 ADDED
Binary file
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "2.7.2",
4
- "description": "Node.js client for Bkper REST API",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "files": [
8
- "lib/**/*"
9
- ],
3
+ "version": "3.1.0",
4
+ "description": "Node.js command line client for Bkper",
10
5
  "bin": {
11
6
  "bkper": "./lib/cli.js"
12
7
  },
@@ -15,19 +10,18 @@
15
10
  "author": "mael <mael@bkper.com>",
16
11
  "license": "Apache-2.0",
17
12
  "private": false,
13
+ "main": "./lib/index.js",
14
+ "module": "./lib/index.js",
15
+ "types": "./lib/index.d.ts",
16
+ "type": "module",
18
17
  "scripts": {
19
- "test": "env TS_NODE_COMPILER_OPTIONS='{\"rootDir\": \".\" }' mocha -r ts-node/register 'test/**/*.ts'",
20
- "clean": "gts clean",
18
+ "clean": "rm -rf ./lib & rm -rf ./node_modules & wait",
19
+ "prebuild": "bun install",
21
20
  "build": "run-s build:*",
22
- "build:clean": "bun clean",
23
- "build:test": "bun run test",
21
+ "build:clean": "gts clean",
24
22
  "build:compile": "tsc",
25
- "build:api": "api-extractor run --local",
26
- "build:cleanup": "rimraf lib/**/*.map lib/*.map lib/**/*.d.ts lib/*.d.ts",
27
- "build:dts": "cp dist/bkper-public.d.ts lib/index.d.ts",
28
- "build:clean-dist": "rimraf dist",
23
+ "prewatch": "bun run build",
29
24
  "watch": "tsc -w",
30
- "upgrade:api": "bun upgrade @bkper/bkper-api-types --latest",
31
25
  "patch": "yarn version --patch",
32
26
  "minor": "yarn version --minor",
33
27
  "major": "yarn version --major",
@@ -35,32 +29,19 @@
35
29
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
36
30
  },
37
31
  "dependencies": {
38
- "@google-cloud/local-auth": "^1.0.0",
39
- "big.js": "^6.0.3",
32
+ "@google-cloud/local-auth": "^3.0.1",
33
+ "bkper-js": "^1.1.0",
40
34
  "commander": "^6.2.1",
41
- "dayjs": "^1.10.3",
42
35
  "dotenv": "^8.2.0",
43
- "gaxios": "^4.3.0",
44
- "google-auth-library": "^6.1.4",
45
- "luxon": "^1.25.0",
46
- "open": "^7.3.1"
36
+ "google-auth-library": "^9.14.0"
47
37
  },
48
38
  "devDependencies": {
49
39
  "@bkper/bkper-api-types": "^5.9.0",
50
- "@microsoft/api-extractor": "^7.12.1",
51
- "@types/big.js": "^6.0.2",
52
- "@types/chai": "^4.2.14",
53
40
  "@types/commander": "^2.12.2",
54
- "@types/luxon": "^1.25.1",
55
- "@types/mocha": "^8.2.0",
56
- "@types/node": "^14.14.20",
57
- "@types/node-fetch": "^2.5.8",
58
- "chai": "^4.2.0",
41
+ "@types/node": "^22.5.1",
59
42
  "gts": "^3.0.3",
60
- "mocha": "^8.2.1",
61
43
  "npm-run-all": "^4.1.5",
62
44
  "rimraf": "^3.0.2",
63
- "ts-node": "^9.1.1",
64
- "typescript": "^4.1.3"
45
+ "typescript": "^5.5.4"
65
46
  }
66
47
  }
@@ -0,0 +1,12 @@
1
+ {
2
+ "installed": {
3
+ "client_id": "360398463400-l3sfmb1tipagc7bfh4tf2eptu1b62g7c.apps.googleusercontent.com",
4
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
5
+ "token_uri": "https://oauth2.googleapis.com/token",
6
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
7
+ "client_secret": "iQ87o7Y9xks1T0tKC7qmhnPw",
8
+ "redirect_uris": [
9
+ "http://localhost:3000/oauth2callback"
10
+ ]
11
+ }
12
+ }
@@ -0,0 +1,79 @@
1
+ import {authenticate} from '@google-cloud/local-auth';
2
+ import fs from 'fs';
3
+ import { Credentials, OAuth2Client } from "google-auth-library";
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
12
+
13
+ const keys = require(`${__dirname}/keys.json`);
14
+
15
+ let storedCredentials: Credentials;
16
+
17
+ const storedCredentialsPath = `${os.homedir}/.bkper-credentials.json`;
18
+
19
+ try {
20
+ let credentialsJson = fs.readFileSync(storedCredentialsPath, 'utf8');
21
+ storedCredentials = JSON.parse(credentialsJson);
22
+ } catch (err) {
23
+ console.log('No local credentials found.');
24
+ }
25
+
26
+ export async function login() {
27
+ if (storedCredentials) {
28
+ console.log('Bkper already logged in.');
29
+ }
30
+ await getOAuthToken();
31
+ }
32
+
33
+ export function logout() {
34
+ if (fs.existsSync(storedCredentialsPath)) {
35
+ fs.rmSync(storedCredentialsPath);
36
+ }
37
+ console.log('Bkper logged out.');
38
+ }
39
+
40
+ export function isLoggedIn() {
41
+ return storedCredentials != null;
42
+ }
43
+
44
+ export async function getOAuthToken(): Promise<string> {
45
+
46
+ let localAuth: OAuth2Client
47
+
48
+ if (storedCredentials) {
49
+ localAuth = new OAuth2Client(
50
+ keys.installed.client_id,
51
+ keys.installed.client_secret,
52
+ keys.installed.redirect_uris[0]
53
+ );
54
+ localAuth.setCredentials(storedCredentials);
55
+ } else {
56
+ localAuth = await authenticate({
57
+ scopes: ['https://www.googleapis.com/auth/userinfo.email'],
58
+ keyfilePath: `${__dirname}/keys.json`,
59
+ });
60
+ storeCredentials(localAuth.credentials);
61
+ }
62
+
63
+ localAuth.on('tokens', (tokens) => {
64
+ if (tokens.refresh_token) {
65
+ // store the refresh_token in my database!
66
+ storeCredentials(tokens)
67
+ }
68
+ });
69
+
70
+ let token = await localAuth.getAccessToken();
71
+
72
+ return token.token || '';
73
+
74
+ }
75
+
76
+ function storeCredentials(credentials: Credentials) {
77
+ storedCredentials = credentials;
78
+ fs.writeFileSync(storedCredentialsPath, JSON.stringify(credentials, null, 4), 'utf8');
79
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { App, Bkper } from 'bkper-js';
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';
8
+
9
+ program
10
+ .command('login')
11
+ .description('Login Bkper')
12
+ .action(async () => {
13
+ await login()
14
+ });
15
+
16
+ program
17
+ .command('logout')
18
+ .description('Logout Bkper')
19
+ .action((todo) => {
20
+ logout()
21
+ });
22
+
23
+ program
24
+ .command('app')
25
+ .description('Create/Update an App')
26
+ .option('-u, --update', 'Update the App')
27
+ .option('-c, --create', 'Create a new App')
28
+ .action(async (options) => {
29
+
30
+ try {
31
+ Bkper.setConfig(getBkperLocalConfig())
32
+ const json: bkper.App = JSON.parse(fs.readFileSync('./bkperapp.json', 'utf8'));
33
+ let app = new App(json)
34
+ .setReadme(fs.readFileSync('./README.md', 'utf8'))
35
+ .setClientSecret(process.env.BKPER_CLIENT_SECRET)
36
+ .setDeveloperEmail(process.env.BKPER_DEVELOPER_EMAIL)
37
+ .setUserEmails(process.env.BKPER_USER_EMAILS);
38
+ if (options.update) {
39
+ app = await app.update();
40
+ console.log(`Updated ${app.getId()} sucessfully.`)
41
+ } else if (options.create) {
42
+ app = await app.create();
43
+ console.log(`Created ${app.getId()} sucessfully.`)
44
+
45
+ }
46
+ } catch (err) {
47
+ console.log(err)
48
+ }
49
+
50
+ });
51
+
52
+
53
+ program.parse(process.argv);
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 ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "extends": "./node_modules/gts/tsconfig-google.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "lib",
6
+ "module": "ESNext",
7
+ "moduleResolution": "Node",
8
+ "resolveJsonModule": true,
9
+ "typeRoots" : ["node_modules/@bkper", "node_modules/@types" ],
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "target": "es2015",
13
+ "declaration": true,
14
+ "sourceMap": true,
15
+ "declarationMap": true
16
+ },
17
+ "include": [
18
+ "src/**/*.json",
19
+ "src/**/*.ts",
20
+ "test/**/*.ts"
21
+ ],
22
+ "exclude": [
23
+ "./test/",
24
+ "./node_modules/",
25
+ "./lib/"
26
+ ]
27
+ }
@@ -1,12 +0,0 @@
1
- {
2
- "installed": {
3
- "client_id": "360398463400-l3sfmb1tipagc7bfh4tf2eptu1b62g7c.apps.googleusercontent.com",
4
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
5
- "token_uri": "https://oauth2.googleapis.com/token",
6
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
7
- "client_secret": "iQ87o7Y9xks1T0tKC7qmhnPw",
8
- "redirect_uris": [
9
- "http://localhost:3000/oauth2callback"
10
- ]
11
- }
12
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getOAuthToken = exports.isLoggedIn = exports.logout = exports.login = void 0;
16
- const local_auth_1 = require("@google-cloud/local-auth");
17
- const fs_1 = __importDefault(require("fs"));
18
- const google_auth_library_1 = require("google-auth-library");
19
- const os_1 = __importDefault(require("os"));
20
- const keys = require(`${__dirname}/keys.json`);
21
- let storedCredentials;
22
- const storedCredentialsPath = `${os_1.default.homedir}/.bkper-credentials.json`;
23
- try {
24
- let credentialsJson = fs_1.default.readFileSync(storedCredentialsPath, 'utf8');
25
- storedCredentials = JSON.parse(credentialsJson);
26
- }
27
- catch (err) {
28
- console.log('No local credentials found.');
29
- }
30
- function login() {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- if (storedCredentials) {
33
- console.log('Bkper already logged in.');
34
- }
35
- yield getOAuthToken();
36
- });
37
- }
38
- exports.login = login;
39
- function logout() {
40
- if (fs_1.default.existsSync(storedCredentialsPath)) {
41
- fs_1.default.unlinkSync(storedCredentialsPath);
42
- }
43
- console.log('Bkper logged out.');
44
- }
45
- exports.logout = logout;
46
- function isLoggedIn() {
47
- return storedCredentials != null;
48
- }
49
- exports.isLoggedIn = isLoggedIn;
50
- function getOAuthToken() {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- let localAuth;
53
- if (storedCredentials) {
54
- localAuth = new google_auth_library_1.OAuth2Client(keys.installed.client_id, keys.installed.client_secret, keys.installed.redirect_uris[0]);
55
- localAuth.setCredentials(storedCredentials);
56
- }
57
- else {
58
- localAuth = yield local_auth_1.authenticate({
59
- scopes: ['https://www.googleapis.com/auth/userinfo.email'],
60
- keyfilePath: `${__dirname}/keys.json`,
61
- });
62
- storeCredentials(localAuth.credentials);
63
- }
64
- localAuth.on('tokens', (tokens) => {
65
- if (tokens.refresh_token) {
66
- // store the refresh_token in my database!
67
- console.log(tokens.refresh_token);
68
- storeCredentials(tokens);
69
- }
70
- });
71
- let token = yield localAuth.getAccessToken();
72
- return token.token;
73
- });
74
- }
75
- exports.getOAuthToken = getOAuthToken;
76
- function storeCredentials(credentials) {
77
- storedCredentials = credentials;
78
- fs_1.default.writeFileSync(storedCredentialsPath, JSON.stringify(credentials, null, 4), 'utf8');
79
- }
80
- //# sourceMappingURL=local-auth-service.js.map
package/lib/cli.js DELETED
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- const commander_1 = __importDefault(require("commander"));
17
- const local_auth_service_1 = require("./auth/local-auth-service");
18
- const Bkper_1 = require("./model/Bkper");
19
- const utils_1 = require("./utils");
20
- const App_1 = require("./model/App");
21
- var fs = require('fs');
22
- require('dotenv').config();
23
- process.env.NODE_ENV = utils_1.NODE_ENV_DEV;
24
- commander_1.default
25
- .command('login')
26
- .description('Login Bkper')
27
- .action(() => __awaiter(void 0, void 0, void 0, function* () {
28
- yield local_auth_service_1.login();
29
- }));
30
- commander_1.default
31
- .command('logout')
32
- .description('Logout Bkper')
33
- .action((todo) => {
34
- local_auth_service_1.logout();
35
- });
36
- commander_1.default
37
- .command('app')
38
- .description('Create/Update an App')
39
- .option('-u, --update', 'Update the App')
40
- .option('-c, --create', 'Create a new App')
41
- .action((options) => __awaiter(void 0, void 0, void 0, function* () {
42
- try {
43
- Bkper_1.Bkper.setConfig({ apiKeyProvider: () => __awaiter(void 0, void 0, void 0, function* () { return process.env.BKPER_API_KEY; }) });
44
- let app = new App_1.App();
45
- app.setJson(JSON.parse(fs.readFileSync('./bkperapp.json', 'utf8')))
46
- .setReadme(fs.readFileSync('./README.md', 'utf8'))
47
- .setClientSecret(process.env.BKPER_CLIENT_SECRET)
48
- .setDeveloperEmail(process.env.BKPER_DEVELOPER_EMAIL)
49
- .setUserEmails(process.env.BKPER_USER_EMAILS);
50
- if (options.update) {
51
- app = yield app.update();
52
- console.log(`Updated ${app.getId()} sucessfully.`);
53
- }
54
- else if (options.create) {
55
- app = yield app.create();
56
- console.log(`Created ${app.getId()} sucessfully.`);
57
- }
58
- }
59
- catch (err) {
60
- console.log(err);
61
- }
62
- }));
63
- commander_1.default.parse(process.argv);
64
- //# sourceMappingURL=cli.js.map