Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert backend to TypeScript (50% -> [...]) #4731

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
094895e
server-ts: Enable ts-node instead of nodemon
eliandoran Feb 16, 2024
39627a4
server-ts: log.js -> log.ts
eliandoran Feb 16, 2024
bda11fa
server-ts: Fix errors in log.ts
eliandoran Feb 16, 2024
981221d
server-ts: data_dir.js -> data_dir.ts
eliandoran Feb 16, 2024
78f6313
server-ts: cls.js -> cls.ts
eliandoran Feb 16, 2024
96b6d17
server-ts: Remove need for 'allowImportingTsExtensions'
eliandoran Feb 16, 2024
ff2e05f
server-ts: Fix references to cls.js
eliandoran Feb 16, 2024
28735fa
server-ts: Fix build errors
eliandoran Feb 16, 2024
7a93654
server-ts: utils.js -> utils.ts
eliandoran Feb 16, 2024
e2a727e
server-ts: date_utils.js -> date_utils.ts
eliandoran Feb 16, 2024
82a9808
server-ts: sql.js -> sql.ts
eliandoran Feb 16, 2024
d3c9e7e
server-ts: errors/*.js -> .ts
eliandoran Feb 16, 2024
dc359b2
server-ts: resource_dir.js -> ts
eliandoran Feb 16, 2024
c20d227
server-ts: services/encryption/*.js -> ts
eliandoran Feb 16, 2024
b63e870
server-ts: protected_session.js -> ts
eliandoran Feb 16, 2024
786d851
server-ts: events.js -> ts
eliandoran Feb 16, 2024
5309d4a
server-ts: instance_id.js -> ts
eliandoran Feb 16, 2024
3a7d0d1
server-ts: Add some type fixes to sql.ts
eliandoran Feb 16, 2024
85af0a2
server-ts: Convert becca.js
eliandoran Feb 16, 2024
cb14d4d
server-ts: Convert blob.js
eliandoran Feb 16, 2024
e04bd5a
server-ts: Convert more classes, including entity_changes.js
eliandoran Feb 16, 2024
6dd2cd3
server-ts: Convert a few classes in becca
eliandoran Feb 16, 2024
768aaf2
server-ts: Port boption
eliandoran Feb 16, 2024
2f15d79
server-ts: Port betapi_token
eliandoran Feb 16, 2024
eef8297
server-ts: Port bblob
eliandoran Feb 16, 2024
06287da
server-ts: Port battribute
eliandoran Feb 16, 2024
4b1d2c6
server-ts: Port options service
eliandoran Feb 16, 2024
cf18e61
server-ts: Port ws service & dependencies
eliandoran Feb 16, 2024
f51f070
server-ts: Port bbranch (with some build errors)
eliandoran Feb 17, 2024
f9ba8ca
server-ts: Fix errors in abstract_becca_entity
eliandoran Feb 17, 2024
9aec339
server-ts: Fix most errors in bnote
eliandoran Feb 17, 2024
3a20bef
server-ts: Fix more errors in becca entities
eliandoran Feb 17, 2024
2c0063a
server-ts: Remove .js extensions in src/becca
eliandoran Feb 17, 2024
26388ad
server-ts: Fix errors in becca-interface
eliandoran Feb 17, 2024
2f96dc2
server-ts: Fix most type errors in becca
eliandoran Feb 17, 2024
8b250e4
server-ts: Fix references to js files for converted files
eliandoran Feb 17, 2024
030aec2
server-ts: Fix more references to js files for converted files
eliandoran Feb 17, 2024
4df599f
server-ts: Fix some build errors
eliandoran Feb 17, 2024
45a6c95
server-ts: Fix references to js files for converted files
eliandoran Feb 17, 2024
b8ccf5b
server-ts: Fix error with sanitize_attribute_name
eliandoran Feb 17, 2024
6f0659c
server-ts: Bring back nodemon
eliandoran Feb 17, 2024
8af5434
server-ts: Add script to check progress
eliandoran Feb 17, 2024
1e91db8
server-ts: Implement review comments
eliandoran Feb 17, 2024
a06aa9d
server-ts: Port anonymization service
eliandoran Feb 17, 2024
9826fed
server-ts: Port app* services
eliandoran Feb 17, 2024
a183f21
server-ts: Convert attribute_formatter
eliandoran Feb 17, 2024
5916a8b
server-ts: Fix build errors
eliandoran Feb 17, 2024
6b8ee08
server-ts: Port keyboard_actions
eliandoran Feb 17, 2024
8936a3f
server-ts: Port backup service
eliandoran Feb 17, 2024
a58abff
server-ts: Port migration service
eliandoran Feb 17, 2024
246a90d
server-ts: Port revisions service
eliandoran Feb 17, 2024
56ca0ea
server-ts: Port migration, port, sql_init services
eliandoran Feb 17, 2024
1b58dbe
server-ts: Port etapi_tokens service
eliandoran Feb 17, 2024
a029ee2
server-ts: Fix export
eliandoran Feb 17, 2024
1c7532d
server-ts: Port sync_options
eliandoran Feb 17, 2024
3b7812f
server-ts: Port becca/entity_constructor
eliandoran Feb 17, 2024
9f99b42
server-ts: Port becca/becca_service
eliandoran Feb 17, 2024
3d5ef81
server-ts: Simplify deferred promise in sql_init
eliandoran Feb 17, 2024
d35613f
server-ts: Port becca_loader
eliandoran Feb 17, 2024
748a551
server-ts: Port similarity
eliandoran Feb 17, 2024
45582eb
server-ts: Port services/meta/*
eliandoran Feb 17, 2024
f31d788
server-ts: Port services/auth
eliandoran Feb 17, 2024
77fb7bc
server-ts: Port services/erase
eliandoran Feb 17, 2024
00c692c
server-ts: Port services/note_types
eliandoran Feb 17, 2024
dc22d05
server-ts: Port services/html_sanitizer
eliandoran Feb 17, 2024
6699889
server-ts: Port services/request
eliandoran Feb 17, 2024
de7f4de
server-ts: Port services/notes & hidden_subtree
eliandoran Feb 17, 2024
5d68372
server-ts: Change data type
eliandoran Feb 17, 2024
1010d11
server-ts: Port services/hoisted_note
eliandoran Feb 17, 2024
fbf77f3
server-ts: Port services/search/search_context
eliandoran Feb 17, 2024
80e6ced
server-ts: Port services/search/search_result
eliandoran Feb 17, 2024
216f3f2
server-ts: Port services/search/value_extractor
eliandoran Feb 17, 2024
ce60fc0
server-ts: Port services/search/expressions/expression
eliandoran Feb 17, 2024
414515b
server-ts: Port services/search/expressions/ancestor
eliandoran Feb 17, 2024
8d2eddd
server-ts: Port services/search/expressions/true
eliandoran Feb 17, 2024
7018cc7
server-ts: Port services/search/expressions/and
eliandoran Feb 17, 2024
0df4886
server-ts: Port services/search/expressions/attribute_exists
eliandoran Feb 17, 2024
ccc51e0
server-ts: Port services/search/expressions/child_of
eliandoran Feb 17, 2024
35886c3
server-ts: Port services/search/expressions/descendant_of
eliandoran Feb 17, 2024
acb31b6
server-ts: Port services/search/expressions/is_hidden
eliandoran Feb 17, 2024
571c9f5
server-ts: Port services/search/expressions/label_comparison
eliandoran Feb 17, 2024
3df6acd
server-ts: Port services/search/expressions/not
eliandoran Feb 17, 2024
414964e
server-ts: Port services/search/expressions/note_content_fulltext
eliandoran Feb 17, 2024
460982d
server-ts: Port services/search/expressions/note_flat_text
eliandoran Feb 17, 2024
c63d05b
server-ts: Port services/search/expressions/or
eliandoran Feb 17, 2024
87708aa
server-ts: Port services/search/expressions/order_by_and_limit
eliandoran Feb 17, 2024
0f7f0ce
server-ts: Port services/search/expressions/parent_of
eliandoran Feb 17, 2024
f5b690d
server-ts: Port services/search/expressions/relation_where
eliandoran Feb 17, 2024
8acb641
server-ts: Port services/search/services/build_comparator
eliandoran Feb 17, 2024
deed58c
server-ts: Port services/search/services/handle_parens
eliandoran Feb 17, 2024
533a597
server-ts: Port services/search/services/lex
eliandoran Feb 17, 2024
29b3fb3
server-ts: Port services/search/expressions/property_comparison
eliandoran Feb 17, 2024
1516928
server-ts: Port services/search/services/parse
eliandoran Feb 18, 2024
2fbd2e3
server-ts: Port services/search/services/search
eliandoran Feb 18, 2024
d8d7293
server-ts: Port services/attributes
eliandoran Feb 18, 2024
0d4fb42
server-ts: Port services/tree
eliandoran Feb 18, 2024
9ea4fcd
server-ts: Port services/branches
eliandoran Feb 18, 2024
ddcbb29
server-ts: Update script to display remaining filelist
eliandoran Feb 18, 2024
330334d
server-ts: Port services/window
eliandoran Feb 18, 2024
3ea4b7a
server-ts: Port services/tray
eliandoran Feb 18, 2024
0ba80b1
server-ts: Port services/sync_update
eliandoran Feb 18, 2024
43c89c0
server-ts: Port services/content_hash
eliandoran Feb 18, 2024
d89b791
server-ts: Port services/sync
eliandoran Feb 18, 2024
e4556af
server-ts: Port services/session_secret
eliandoran Feb 18, 2024
6cedad0
server-ts: Port services/cloning
eliandoran Feb 18, 2024
6df09cb
server-ts: Port services/bulk_actions
eliandoran Feb 18, 2024
dbccf6b
server-ts: Port services/one_time_timer
eliandoran Feb 18, 2024
45cb7ce
server-ts: Port services/host
eliandoran Feb 18, 2024
5f4f30f
server-ts: Port services/options_init
eliandoran Feb 18, 2024
3030fbe
server-ts: Port services/notes
eliandoran Feb 18, 2024
91ddabb
server-ts: Remove redundant file
eliandoran Feb 18, 2024
3d9da26
server-ts: Address review comments
eliandoran Feb 18, 2024
aff1c30
server-ts: FIXME -> TODO
eliandoran Feb 18, 2024
11c7533
Merge branch 'feature/typescript_backend' into feature/typescript_bac…
eliandoran Feb 18, 2024
cbc01e1
server-ts: FIXME -> TODO
eliandoran Feb 18, 2024
0903cf2
Merge branch 'feature/typescript_backend_2' into feature/typescript_b…
eliandoran Feb 18, 2024
ec4bd66
server-ts: Port services/export/md
eliandoran Feb 19, 2024
cfeb0cc
server-ts: Port services/export/opml
eliandoran Feb 19, 2024
1728365
server-ts: Port services/export/single
eliandoran Feb 19, 2024
29d37c4
server-ts: Port services/export/zip
eliandoran Feb 19, 2024
fa0ed35
server-ts: Port services/image
eliandoran Feb 20, 2024
052a0a4
server-ts: Port services/import/utils
eliandoran Feb 25, 2024
fd37fd3
server-ts: Port services/import/mime
eliandoran Feb 25, 2024
cc1a545
server-ts: Port services/import/opml
eliandoran Feb 25, 2024
59d618f
server-ts: Port services/import/markdown
eliandoran Feb 25, 2024
7f01021
server-ts: Port services/import/single
eliandoran Feb 25, 2024
8c5f680
server-ts: Fix build errors
eliandoran Feb 25, 2024
9f6a8dc
server-ts: Fix undefined in ws
eliandoran Mar 17, 2024
040ed39
server-ts: Fix undefined in task_context
eliandoran Mar 17, 2024
cbad582
server-ts: Solve requested changes
eliandoran Mar 17, 2024
926b3e9
Merge remote-tracking branch 'origin/develop' into feature/typescript…
eliandoran Mar 17, 2024
5e5add7
Merge remote-tracking branch 'origin/develop' into feature/typescript…
eliandoran Mar 30, 2024
3eb7ed5
server-ts: Address requested changes
eliandoran Mar 30, 2024
db2b337
Merge branch 'feature/typescript_backend' into feature/typescript_bac…
eliandoran Mar 30, 2024
08f0c01
server-ts: Solve build errors after merge
eliandoran Mar 30, 2024
b84b276
server-ts: Fix some issues from self-review
eliandoran Apr 2, 2024
090d353
Merge branch 'feature/typescript_backend_2' into feature/typescript_b…
eliandoran Apr 2, 2024
a420129
server-ts: Fix build errors after merge
eliandoran Apr 2, 2024
d4c8d24
server-ts: Address some review comments
eliandoran Apr 2, 2024
99d5095
server-ts: Address self-review
eliandoran Apr 2, 2024
0daa4cc
Merge branch 'feature/typescript_backend_3' into feature/typescript_b…
eliandoran Apr 2, 2024
e96b56e
server-ts: Fix build errors
eliandoran Apr 2, 2024
a354b54
server-ts: Fix getContent in updateNoteData
eliandoran Apr 3, 2024
f857b8a
server-ts: Refactor out abstract init in entities
eliandoran Apr 3, 2024
5d452a1
server-ts: Address review
eliandoran Apr 3, 2024
17c7e2d
server-ts: Address further suggestions
eliandoran Apr 3, 2024
5baabec
Merge branch 'feature/typescript_backend_2' into feature/typescript_b…
eliandoran Apr 3, 2024
ed47c23
Merge branch 'feature/typescript_backend_3' into feature/typescript_b…
eliandoran Apr 3, 2024
aa233b8
server-ts: Port consistency_checks
eliandoran Apr 3, 2024
764d251
server-ts: Port services/import/enex
eliandoran Mar 17, 2024
53d4873
server-ts: Port services/import/zip
eliandoran Apr 3, 2024
915de23
server-ts: Port services/anonymize
eliandoran Apr 3, 2024
16283d4
server-ts: Port services/spaced_update
eliandoran Apr 3, 2024
984ce49
server-ts: Port services/special_notes
eliandoran Apr 3, 2024
532ed1d
server-ts: Port services/setup
eliandoran Apr 3, 2024
a154dc7
server-ts: Port services/options
eliandoran Apr 3, 2024
15dee4b
server-ts: Convert services/backend_script_api
eliandoran Apr 4, 2024
884b661
server-ts: Convert services/script_context
eliandoran Apr 4, 2024
59c533c
server-ts: Convert services/script
eliandoran Apr 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"editor.formatOnSave": true,
"files.eol": "\n"
"files.eol": "\n",
"typescript.tsdk": "node_modules/typescript/lib"
}
10 changes: 10 additions & 0 deletions _check_ts_progress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

cloc HEAD \
--git --md \
--include-lang=javascript,typescript \
--found=filelist.txt \
--exclude-dir=public,libraries

grep -R \.js$ filelist.txt
rm filelist.txt
2 changes: 1 addition & 1 deletion bin/create-anonymization-script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const anonymizationService = require('../src/services/anonymization.js');
const anonymizationService = require('../src/services/anonymization');
const fs = require('fs');
const path = require('path');

Expand Down
4 changes: 2 additions & 2 deletions bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jq '.version = "'$VERSION'"' package.json|sponge package.json

git add package.json

echo 'module.exports = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > src/services/build.js
echo 'export = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > src/services/build.ts

git add src/services/build.js
git add src/services/build.ts

TAG=v$VERSION

Expand Down
4 changes: 2 additions & 2 deletions db/migrations/0216__move_content_into_blobs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = () => {
const sql = require('../../src/services/sql.js');
const utils = require('../../src/services/utils.js');
const sql = require('../../src/services/sql');
const utils = require('../../src/services/utils');

const existingBlobIds = new Set();

Expand Down
12 changes: 6 additions & 6 deletions db/migrations/0220__migrate_images_to_attachments.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = () => {
const beccaLoader = require('../../src/becca/becca_loader.js');
const becca = require('../../src/becca/becca.js');
const cls = require('../../src/services/cls.js');
const log = require('../../src/services/log.js');
const sql = require('../../src/services/sql.js');
const beccaLoader = require('../../src/becca/becca_loader');
const becca = require('../../src/becca/becca');
const cls = require('../../src/services/cls');
const log = require('../../src/services/log');
const sql = require('../../src/services/sql');

cls.init(() => {
// emergency disabling of image compression since it appears to make problems in migration to 0.61
Expand All @@ -13,7 +13,7 @@ module.exports = () => {

for (const note of Object.values(becca.notes)) {
try {
const attachment = note.convertToParentAttachment({autoConversion: true});
const attachment = note.convertToParentAttachment({ autoConversion: true });

if (attachment) {
log.info(`Auto-converted note '${note.noteId}' into attachment '${attachment.attachmentId}'.`);
Expand Down
6 changes: 3 additions & 3 deletions docker_healthcheck.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const http = require("http");
const ini = require("ini");
const fs = require("fs");
const dataDir = require('./src/services/data_dir.js');
const dataDir = require('./src/services/data_dir');
const config = ini.parse(fs.readFileSync(dataDir.CONFIG_INI_PATH, 'utf-8'));

if (config.Network.https) {
Expand All @@ -10,8 +10,8 @@ if (config.Network.https) {
process.exit(0);
}

const port = require('./src/services/port.js');
const host = require('./src/services/host.js');
const port = require('./src/services/port');
const host = require('./src/services/host');

const options = { timeout: 2000 };

Expand Down
2 changes: 1 addition & 1 deletion dump-db/inc/data_key.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const crypto = require("crypto");
const sql = require('./sql.js');
const sql = require('./sql');
const decryptService = require('./decrypt.js');

function getDataKey(password) {
Expand Down
6 changes: 3 additions & 3 deletions dump-db/inc/dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function dumpDocument(documentPath, targetPath, options) {
return;
}

let {content} = sql.getRow("SELECT content FROM blobs WHERE blobId = ?", [noteRow.blobId]);
let { content } = sql.getRow("SELECT content FROM blobs WHERE blobId = ?", [noteRow.blobId]);

if (content !== null && noteRow.isProtected && dataKey) {
content = decryptService.decrypt(dataKey, content);
Expand Down Expand Up @@ -108,7 +108,7 @@ function dumpDocument(documentPath, targetPath, options) {
}

try {
fs.mkdirSync(childTargetPath, {recursive: true});
fs.mkdirSync(childTargetPath, { recursive: true });
}
catch (e) {
console.error(`DUMPERROR: Creating directory ${childTargetPath} failed with error '${e.message}'`);
Expand Down Expand Up @@ -157,7 +157,7 @@ function validatePaths(documentPath, targetPath) {
}

if (!fs.existsSync(targetPath)) {
const ret = fs.mkdirSync(targetPath, {recursive: true});
const ret = fs.mkdirSync(targetPath, { recursive: true });

if (!ret) {
console.error(`Target path '${targetPath}' could not be created. Run with --help to see usage.`);
Expand Down
6 changes: 3 additions & 3 deletions electron.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

const {app, globalShortcut, BrowserWindow} = require('electron');
const sqlInit = require('./src/services/sql_init.js');
const sqlInit = require('./src/services/sql_init');
const appIconService = require('./src/services/app_icon.js');
const windowService = require('./src/services/window.js');
const tray = require('./src/services/tray.js');
const windowService = require('./src/services/window');
const tray = require('./src/services/tray');

// Adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();
Expand Down
7 changes: 3 additions & 4 deletions nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
"restartable": "rs",
"ignore": [".git", "node_modules/**/node_modules", "src/public/"],
"verbose": false,
"execMap": {
"js": "node --harmony"
},
"exec": "ts-node",
"watch": ["src/"],
"signal": "SIGTERM",
"env": {
"NODE_ENV": "development"
},
"ext": "js,json"
"ext": "ts,js,json"
}
Loading
Loading