@actual-app/api
Advanced tools
Comparing version 6.4.0 to 6.5.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.q = void 0; | ||
class Query { | ||
@@ -88,2 +89,2 @@ constructor(state) { | ||
} | ||
exports.default = q; | ||
exports.q = q; |
@@ -30,2 +30,3 @@ "use strict"; | ||
exports.shutdown = exports.init = exports.utils = exports.methods = exports.internal = void 0; | ||
// @ts-ignore: bundle not available until we build it | ||
// eslint-disable-next-line import/extensions | ||
@@ -46,3 +47,7 @@ const bundle = __importStar(require("./app/bundle.api.js")); | ||
(0, validateNodeVersion_1.validateNodeVersion)(); | ||
global.fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args)); | ||
if (!globalThis.fetch) { | ||
globalThis.fetch = (url, init) => { | ||
return Promise.resolve().then(() => __importStar(require('node-fetch'))).then(({ default: fetch }) => fetch(url, init)); | ||
}; | ||
} | ||
await bundle.init(config); | ||
@@ -49,0 +54,0 @@ actualApp = bundle.lib; |
@@ -25,10 +25,7 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.deletePayee = exports.updatePayee = exports.createPayee = exports.getPayees = exports.deleteCategory = exports.updateCategory = exports.createCategory = exports.getCategories = exports.deleteCategoryGroup = exports.updateCategoryGroup = exports.createCategoryGroup = exports.deleteAccount = exports.reopenAccount = exports.closeAccount = exports.updateAccount = exports.createAccount = exports.getAccounts = exports.deleteTransaction = exports.updateTransaction = exports.filterTransactions = exports.getTransactions = exports.importTransactions = exports.addTransactions = exports.setBudgetCarryover = exports.setBudgetAmount = exports.getBudgetMonth = exports.getBudgetMonths = exports.runQuery = exports.batchBudgetUpdates = exports.sync = exports.downloadBudget = exports.loadBudget = exports.runImport = exports.q = void 0; | ||
exports.deletePayee = exports.updatePayee = exports.createPayee = exports.getPayees = exports.deleteCategory = exports.updateCategory = exports.createCategory = exports.getCategories = exports.deleteCategoryGroup = exports.updateCategoryGroup = exports.createCategoryGroup = exports.deleteAccount = exports.reopenAccount = exports.closeAccount = exports.updateAccount = exports.createAccount = exports.getAccounts = exports.deleteTransaction = exports.updateTransaction = exports.getTransactions = exports.importTransactions = exports.addTransactions = exports.setBudgetCarryover = exports.setBudgetAmount = exports.getBudgetMonth = exports.getBudgetMonths = exports.runQuery = exports.batchBudgetUpdates = exports.sync = exports.downloadBudget = exports.loadBudget = exports.runImport = exports.q = void 0; | ||
const injected = __importStar(require("./injected")); | ||
var query_1 = require("./app/query"); | ||
Object.defineProperty(exports, "q", { enumerable: true, get: function () { return __importDefault(query_1).default; } }); | ||
Object.defineProperty(exports, "q", { enumerable: true, get: function () { return query_1.q; } }); | ||
function send(name, args) { | ||
@@ -108,6 +105,2 @@ return injected.send(name, args); | ||
exports.getTransactions = getTransactions; | ||
function filterTransactions(accountId, text) { | ||
return send('api/transactions-filter', { accountId, text }); | ||
} | ||
exports.filterTransactions = filterTransactions; | ||
function updateTransaction(id, fields) { | ||
@@ -114,0 +107,0 @@ return send('api/transaction-update', { id, fields }); |
@@ -26,2 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// @ts-strict-ignore | ||
const fs = __importStar(require("fs/promises")); | ||
@@ -232,2 +233,75 @@ const path = __importStar(require("path")); | ||
}); | ||
// apis: createPayee, getPayees, updatePayee, deletePayee | ||
test('Payees: successfully update payees', async () => { | ||
const payeeId1 = await api.createPayee({ name: 'test-payee1' }); | ||
const payeeId2 = await api.createPayee({ name: 'test-payee2' }); | ||
let payees = await api.getPayees(); | ||
// payees successfully created | ||
expect(payees).toEqual(expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: payeeId1, | ||
name: 'test-payee1', | ||
}), | ||
expect.objectContaining({ | ||
id: payeeId2, | ||
name: 'test-payee2', | ||
}), | ||
])); | ||
await api.updatePayee(payeeId1, { name: 'test-updated-payee' }); | ||
await api.deletePayee(payeeId2); | ||
// confirm update and delete were successful | ||
payees = await api.getPayees(); | ||
expect(payees).toEqual(expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: payeeId1, | ||
name: 'test-updated-payee', | ||
}), | ||
expect.not.objectContaining({ | ||
name: 'test-payee1', | ||
}), | ||
expect.not.objectContaining({ | ||
id: payeeId2, | ||
}), | ||
])); | ||
}); | ||
// apis: addTransactions, getTransactions, importTransactions, updateTransaction, deleteTransaction | ||
test('Transactions: successfully update transactions', async () => { | ||
const accountId = await api.createAccount({ name: 'test-account' }, 0); | ||
let newTransaction = [ | ||
{ date: '2023-11-03', imported_id: '11', amount: 100 }, | ||
{ date: '2023-11-03', imported_id: '11', amount: 100 }, | ||
]; | ||
const addResult = await api.addTransactions(accountId, newTransaction, { | ||
learnCategories: true, | ||
runTransfers: true, | ||
}); | ||
expect(addResult).toBe('ok'); | ||
// confirm added transactions exist | ||
let transactions = await api.getTransactions(accountId, '2023-11-01', '2023-11-30'); | ||
expect(transactions).toEqual(expect.arrayContaining(newTransaction.map(trans => expect.objectContaining(trans)))); | ||
expect(transactions).toHaveLength(2); | ||
newTransaction = [ | ||
{ date: '2023-12-03', imported_id: '11', amount: 100 }, | ||
{ date: '2023-12-03', imported_id: '22', amount: 200 }, | ||
]; | ||
const reconciled = await api.importTransactions(accountId, newTransaction); | ||
// Expect it to reconcile and to have updated one of the previous transactions | ||
expect(reconciled.added).toHaveLength(1); | ||
expect(reconciled.updated).toHaveLength(1); | ||
// confirm imported transactions exist | ||
transactions = await api.getTransactions(accountId, '2023-12-01', '2023-12-31'); | ||
expect(transactions).toEqual(expect.arrayContaining(newTransaction.map(trans => expect.objectContaining(trans)))); | ||
expect(transactions).toHaveLength(2); | ||
const idToUpdate = reconciled.added[0]; | ||
const idToDelete = reconciled.updated[0]; | ||
await api.updateTransaction(idToUpdate, { amount: 500 }); | ||
await api.deleteTransaction(idToDelete); | ||
// confirm updates and deletions work | ||
transactions = await api.getTransactions(accountId, '2023-12-01', '2023-12-31'); | ||
expect(transactions).toEqual(expect.arrayContaining([ | ||
expect.objectContaining({ id: idToUpdate, amount: 500 }), | ||
expect.not.objectContaining({ id: idToDelete }), | ||
])); | ||
expect(transactions).toHaveLength(1); | ||
}); | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
async function runMigration(db, uuid) { | ||
async function runMigration(db) { | ||
function getValue(node) { | ||
@@ -5,0 +5,0 @@ return node.expr != null ? node.expr : node.cachedValue; |
{ | ||
"name": "@actual-app/api", | ||
"version": "6.4.0", | ||
"version": "6.5.0", | ||
"license": "MIT", | ||
@@ -10,3 +10,3 @@ "description": "An API for Actual", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"types": "@types/index.d.ts", | ||
"files": [ | ||
@@ -17,10 +17,11 @@ "dist" | ||
"build:app": "yarn workspace loot-core build:api", | ||
"build:node": "tsc --p tsconfig.dist.json", | ||
"build:node": "tsc --p tsconfig.dist.json && tsc-alias -p tsconfig.dist.json", | ||
"build:migrations": "cp migrations/*.sql dist/migrations", | ||
"build:default-db": "cp default-db.sqlite dist/", | ||
"build": "rm -rf dist && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db", | ||
"test": "yarn run build:app && jest -c jest.config.js" | ||
"build": "yarn run clean && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db", | ||
"test": "yarn run build:app && jest -c jest.config.js", | ||
"clean": "rm -rf dist @types" | ||
}, | ||
"dependencies": { | ||
"better-sqlite3": "^9.1.1", | ||
"better-sqlite3": "^9.2.2", | ||
"compare-versions": "^6.1.0", | ||
@@ -31,9 +32,10 @@ "node-fetch": "^3.3.2", | ||
"devDependencies": { | ||
"@swc/core": "^1.3.82", | ||
"@swc/jest": "^0.2.29", | ||
"@swc/core": "^1.3.105", | ||
"@swc/jest": "^0.2.31", | ||
"@types/jest": "^27.5.0", | ||
"@types/uuid": "^9.0.2", | ||
"jest": "^27.0.0", | ||
"tsc-alias": "^1.8.8", | ||
"typescript": "^5.0.2" | ||
} | ||
} |
{ | ||
"name": "@actual-app/api", | ||
"version": "6.4.0", | ||
"version": "6.5.0", | ||
"license": "MIT", | ||
@@ -10,3 +10,3 @@ "description": "An API for Actual", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"types": "@types/index.d.ts", | ||
"files": [ | ||
@@ -17,10 +17,11 @@ "dist" | ||
"build:app": "yarn workspace loot-core build:api", | ||
"build:node": "tsc --p tsconfig.dist.json", | ||
"build:node": "tsc --p tsconfig.dist.json && tsc-alias -p tsconfig.dist.json", | ||
"build:migrations": "cp migrations/*.sql dist/migrations", | ||
"build:default-db": "cp default-db.sqlite dist/", | ||
"build": "rm -rf dist && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db", | ||
"test": "yarn run build:app && jest -c jest.config.js" | ||
"build": "yarn run clean && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db", | ||
"test": "yarn run build:app && jest -c jest.config.js", | ||
"clean": "rm -rf dist @types" | ||
}, | ||
"dependencies": { | ||
"better-sqlite3": "^9.1.1", | ||
"better-sqlite3": "^9.2.2", | ||
"compare-versions": "^6.1.0", | ||
@@ -31,9 +32,10 @@ "node-fetch": "^3.3.2", | ||
"devDependencies": { | ||
"@swc/core": "^1.3.82", | ||
"@swc/jest": "^0.2.29", | ||
"@swc/core": "^1.3.105", | ||
"@swc/jest": "^0.2.31", | ||
"@types/jest": "^27.5.0", | ||
"@types/uuid": "^9.0.2", | ||
"jest": "^27.0.0", | ||
"tsc-alias": "^1.8.8", | ||
"typescript": "^5.0.2" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3689404
59095
7
40
Updatedbetter-sqlite3@^9.2.2