@actual-app/sync-server 26.1.0-nightly.20251206 → 26.1.0-nightly.20251208
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/build/bin/actual-server.js +1 -0
- package/build/bin/add-import-extensions.mjs +82 -0
- package/build/src/app-account.js +1 -1
- package/build/src/app-cors-proxy.test.js +3 -3
- package/build/src/app-openid.js +1 -1
- package/build/src/app-sync/tests/services/files-service.test.js +1 -1
- package/package.json +6 -5
- package/src/app-gocardless/README.md +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { readdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { join, dirname, extname, relative, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
const buildDir = resolve(__dirname, '../build');
|
|
9
|
+
async function getAllJsFiles(dir) {
|
|
10
|
+
const files = [];
|
|
11
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
const fullPath = join(dir, entry.name);
|
|
14
|
+
if (entry.isDirectory()) {
|
|
15
|
+
files.push(...(await getAllJsFiles(fullPath)));
|
|
16
|
+
}
|
|
17
|
+
else if (entry.isFile() && extname(entry.name) === '.js') {
|
|
18
|
+
files.push(fullPath);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return files;
|
|
22
|
+
}
|
|
23
|
+
function resolveImportPath(importPath, fromFile) {
|
|
24
|
+
const baseDir = dirname(fromFile);
|
|
25
|
+
const resolvedPath = resolve(baseDir, importPath);
|
|
26
|
+
// Check if it's a file with .js extension
|
|
27
|
+
if (existsSync(`${resolvedPath}.js`)) {
|
|
28
|
+
return `${importPath}.js`;
|
|
29
|
+
}
|
|
30
|
+
// Check if it's a directory with index.js
|
|
31
|
+
if (existsSync(resolvedPath) && existsSync(join(resolvedPath, 'index.js'))) {
|
|
32
|
+
return `${importPath}/index.js`;
|
|
33
|
+
}
|
|
34
|
+
// Verify the file exists before adding extension
|
|
35
|
+
if (!existsSync(`${resolvedPath}.js`)) {
|
|
36
|
+
console.warn(`Warning: Could not resolve import '${importPath}' from ${relative(buildDir, fromFile)}`);
|
|
37
|
+
}
|
|
38
|
+
// Default: assume it's a file and add .js
|
|
39
|
+
return `${importPath}.js`;
|
|
40
|
+
}
|
|
41
|
+
function addExtensionsToImports(content, filePath) {
|
|
42
|
+
// Match relative imports: import ... from './path' or import ... from '../path'
|
|
43
|
+
// Also handle: import('./path') and require('./path')
|
|
44
|
+
const importRegex = /(?:import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*(?:\{[^}]*\}|\*\s+as\s+\w+|\w+))*\s+from\s+)?|import\s*\(|require\s*\()['"](\.\.?\/[^'"]+)['"]/g;
|
|
45
|
+
return content.replace(importRegex, (match, importPath) => {
|
|
46
|
+
// importPath is the second capture group (the path)
|
|
47
|
+
if (!importPath || typeof importPath !== 'string') {
|
|
48
|
+
return match;
|
|
49
|
+
}
|
|
50
|
+
// Skip if already has an extension
|
|
51
|
+
if (/\.(js|mjs|ts|mts|json)$/.test(importPath)) {
|
|
52
|
+
return match;
|
|
53
|
+
}
|
|
54
|
+
// Skip if ends with / (directory import that already has trailing slash)
|
|
55
|
+
if (importPath.endsWith('/')) {
|
|
56
|
+
return match;
|
|
57
|
+
}
|
|
58
|
+
const newImportPath = resolveImportPath(importPath, filePath);
|
|
59
|
+
return match.replace(importPath, newImportPath);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function processFile(filePath) {
|
|
63
|
+
const content = await readFile(filePath, 'utf-8');
|
|
64
|
+
const newContent = addExtensionsToImports(content, filePath);
|
|
65
|
+
if (content !== newContent) {
|
|
66
|
+
await writeFile(filePath, newContent, 'utf-8');
|
|
67
|
+
const relativePath = relative(buildDir, filePath);
|
|
68
|
+
console.log(`Updated imports in ${relativePath}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function main() {
|
|
72
|
+
try {
|
|
73
|
+
const files = await getAllJsFiles(buildDir);
|
|
74
|
+
await Promise.all(files.map(processFile));
|
|
75
|
+
console.log(`Processed ${files.length} files`);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error('Error processing files:', error);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
main();
|
package/build/src/app-account.js
CHANGED
|
@@ -2,7 +2,7 @@ import express from 'express';
|
|
|
2
2
|
import { bootstrap, needsBootstrap, getLoginMethod, listLoginMethods, getUserInfo, getActiveLoginMethod, } from './account-db.js';
|
|
3
3
|
import { isValidRedirectUrl, loginWithOpenIdSetup } from './accounts/openid.js';
|
|
4
4
|
import { changePassword, loginWithPassword } from './accounts/password.js';
|
|
5
|
-
import { errorMiddleware, requestLoggerMiddleware
|
|
5
|
+
import { errorMiddleware, requestLoggerMiddleware } from './util/middlewares.js';
|
|
6
6
|
import { validateAuthHeader, validateSession } from './util/validate-user.js';
|
|
7
7
|
const app = express();
|
|
8
8
|
app.use(express.json());
|
|
@@ -4,15 +4,15 @@ import { vi, describe, it, expect, beforeEach, beforeAll } from 'vitest';
|
|
|
4
4
|
import { handlers as app, clearAllowlistCache } from './app-cors-proxy.js';
|
|
5
5
|
import { config } from './load-config.js';
|
|
6
6
|
import { validateSession } from './util/validate-user.js';
|
|
7
|
-
vi.mock('./load-config
|
|
7
|
+
vi.mock('./load-config', () => ({
|
|
8
8
|
config: {
|
|
9
9
|
get: vi.fn(),
|
|
10
10
|
},
|
|
11
11
|
}));
|
|
12
|
-
vi.mock('./util/middlewares
|
|
12
|
+
vi.mock('./util/middlewares', () => ({
|
|
13
13
|
requestLoggerMiddleware: (req, res, next) => next(),
|
|
14
14
|
}));
|
|
15
|
-
vi.mock('./util/validate-user
|
|
15
|
+
vi.mock('./util/validate-user', () => ({
|
|
16
16
|
validateSession: vi.fn(),
|
|
17
17
|
}));
|
|
18
18
|
vi.mock('express-rate-limit', () => ({
|
package/build/src/app-openid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { disableOpenID, enableOpenID, isAdmin } from './account-db.js';
|
|
3
|
-
import { isValidRedirectUrl, loginWithOpenIdFinalize
|
|
3
|
+
import { isValidRedirectUrl, loginWithOpenIdFinalize } from './accounts/openid.js';
|
|
4
4
|
import { checkPassword } from './accounts/password.js';
|
|
5
5
|
import * as UserService from './services/user-service.js';
|
|
6
6
|
import { errorMiddleware, requestLoggerMiddleware, validateSessionMiddleware, } from './util/middlewares.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import { getAccountDb } from '../../../account-db.js';
|
|
3
3
|
import { FileNotFound } from '../../errors.js';
|
|
4
|
-
import { FilesService, File, FileUpdate
|
|
4
|
+
import { FilesService, File, FileUpdate } from '../../services/files-service.js'; // Adjust the path as necessary
|
|
5
5
|
describe('FilesService', () => {
|
|
6
6
|
let filesService;
|
|
7
7
|
let accountDb;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actual-app/sync-server",
|
|
3
|
-
"version": "26.1.0-nightly.
|
|
3
|
+
"version": "26.1.0-nightly.20251208",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "actual syncing server",
|
|
6
6
|
"bin": {
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"start": "yarn build && node build/app",
|
|
17
|
-
"start-monitor": "nodemon --exec '
|
|
18
|
-
"build": "tsc && yarn copy-static-assets",
|
|
17
|
+
"start-monitor": "nodemon --exec 'yarn build && node build/app' --ignore './build/**/*' --ext 'ts,js' build/app",
|
|
18
|
+
"build": "tsc && yarn add-import-extensions && yarn copy-static-assets",
|
|
19
|
+
"add-import-extensions": "node bin/add-import-extensions.mjs",
|
|
19
20
|
"copy-static-assets": "rm -rf build/src/sql && cp -r src/sql build/src/sql",
|
|
20
|
-
"test": "NODE_ENV=test NODE_OPTIONS='--experimental-vm-modules --trace-warnings' vitest --run",
|
|
21
|
+
"test": "NODE_ENV=test NODE_OPTIONS='--experimental-vm-modules --import ./register-loader.mjs --trace-warnings' vitest --run",
|
|
21
22
|
"db:migrate": "yarn build && cross-env NODE_ENV=development node build/src/scripts/run-migrations.js up",
|
|
22
23
|
"db:downgrade": "yarn build && cross-env NODE_ENV=development node build/src/scripts/run-migrations.js down",
|
|
23
24
|
"db:test-migrate": "yarn build && cross-env NODE_ENV=test node build/src/scripts/run-migrations.js up",
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"@actual-app/crdt": "2.1.0",
|
|
31
|
-
"@actual-app/web": "26.1.0-nightly.
|
|
32
|
+
"@actual-app/web": "26.1.0-nightly.20251208",
|
|
32
33
|
"bcrypt": "^6.0.0",
|
|
33
34
|
"better-sqlite3": "^12.4.1",
|
|
34
35
|
"convict": "^6.2.4",
|