@actual-app/api 2.0.0 → 4.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/index.js CHANGED
@@ -1,10 +1,35 @@
1
- const { init, shutdown } = require('./local');
2
- const methods = require('./methods');
3
- const utils = require('./utils');
1
+ let bundle = require('./app/bundle.api.js');
2
+ let methods = require('./methods');
3
+ let utils = require('./utils');
4
+
5
+ let injected = require('./injected');
6
+ let actualApp;
7
+
8
+ async function init({ budgetId, config } = {}) {
9
+ if (actualApp) {
10
+ return;
11
+ }
12
+
13
+ global.fetch = require('node-fetch');
14
+
15
+ await bundle.init({ budgetId, config });
16
+ actualApp = bundle.lib;
17
+
18
+ injected.send = bundle.lib.send;
19
+ return bundle.lib;
20
+ }
21
+
22
+ async function shutdown() {
23
+ if (actualApp) {
24
+ await actualApp.send('close-budget');
25
+ actualApp = null;
26
+ }
27
+ }
4
28
 
5
29
  module.exports = {
6
30
  init,
7
31
  shutdown,
8
32
  utils,
33
+ internal: bundle.lib,
9
34
  ...methods
10
35
  };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "2.0.0",
3
+ "version": "4.1.0",
4
+ "license": "MIT",
4
5
  "description": "An API for Actual",
5
- "main": "api.js",
6
+ "main": "index.js",
6
7
  "license": "MIT",
7
8
  "dependencies": {
8
9
  "better-sqlite3": "^7.5.0",
package/local.js DELETED
@@ -1,28 +0,0 @@
1
- let injected = require('./injected');
2
- let actualApp;
3
-
4
- async function init({ budgetId, config } = {}) {
5
- if (actualApp) {
6
- return;
7
- }
8
-
9
- process.traceProcessWarnings = true;
10
-
11
- global.fetch = require('node-fetch');
12
- let bundle = require('./app/bundle.api.js');
13
-
14
- await bundle.init({ budgetId, config });
15
- actualApp = bundle.lib;
16
-
17
- injected.send = bundle.lib.send;
18
- return bundle.lib;
19
- }
20
-
21
- async function shutdown() {
22
- if (actualApp) {
23
- await actualApp.send('close-budget');
24
- actualApp = null;
25
- }
26
- }
27
-
28
- module.exports = { init, shutdown };