Skip to content

Commit

Permalink
refactor(ts): enable verbatim module syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Jan 9, 2025
1 parent 4cbb529 commit 324696b
Show file tree
Hide file tree
Showing 161 changed files with 244 additions and 250 deletions.
2 changes: 1 addition & 1 deletion spec/search/becca_mocking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BAttribute from "../../src/becca/entities/battribute.js";
import becca from "../../src/becca/becca.js";
import randtoken from "rand-token";
import SearchResult from "../../src/services/search/search_result.js";
import { NoteType } from "../../src/becca/entities/rows.js";
import type { NoteType } from "../../src/becca/entities/rows.js";
randtoken.generator({ source: "crypto" });

function findNoteByTitle(searchResults: Array<SearchResult>, title: string): BNote | undefined {
Expand Down
2 changes: 1 addition & 1 deletion spec/search/parens.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import handleParens from "../../src/services/search/services/handle_parens.js";
import { TokenStructure } from "../../src/services/search/services/types.js";
import type { TokenStructure } from "../../src/services/search/services/types.js";

describe("Parens handler", () => {
it("handles parens", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/becca/becca-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import BAttribute from "./entities/battribute.js";
import BBranch from "./entities/bbranch.js";
import BRevision from "./entities/brevision.js";
import BAttachment from "./entities/battachment.js";
import { AttachmentRow, BlobRow, RevisionRow } from "./entities/rows.js";
import type { AttachmentRow, BlobRow, RevisionRow } from "./entities/rows.js";
import BBlob from "./entities/bblob.js";
import BRecentNote from "./entities/brecent_note.js";
import AbstractBeccaEntity from "./entities/abstract_becca_entity.js";
Expand Down
2 changes: 1 addition & 1 deletion src/becca/becca_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BOption from "./entities/boption.js";
import BEtapiToken from "./entities/betapi_token.js";
import cls from "../services/cls.js";
import entityConstructor from "../becca/entity_constructor.js";
import { AttributeRow, BranchRow, EtapiTokenRow, NoteRow, OptionRow } from "./entities/rows.js";
import type { AttributeRow, BranchRow, EtapiTokenRow, NoteRow, OptionRow } from "./entities/rows.js";
import AbstractBeccaEntity from "./entities/abstract_becca_entity.js";
import ws from "../services/ws.js";

Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/abstract_becca_entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import cls from "../../services/cls.js";
import log from "../../services/log.js";
import protectedSessionService from "../../services/protected_session.js";
import blobService from "../../services/blob.js";
import Becca, { ConstructorData } from "../becca-interface.js";
import Becca, { type ConstructorData } from "../becca-interface.js";
import becca from "../becca.js";

interface ContentOpts {
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/battachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AbstractBeccaEntity from "./abstract_becca_entity.js";
import sql from "../../services/sql.js";
import protectedSessionService from "../../services/protected_session.js";
import log from "../../services/log.js";
import { AttachmentRow } from "./rows.js";
import type { AttachmentRow } from "./rows.js";
import BNote from "./bnote.js";
import BBranch from "./bbranch.js";
import noteService from "../../services/notes.js";
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/battribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AbstractBeccaEntity from "./abstract_becca_entity.js";
import dateUtils from "../../services/date_utils.js";
import promotedAttributeDefinitionParser from "../../services/promoted_attribute_definition_parser.js";
import sanitizeAttributeName from "../../services/sanitize_attribute_name.js";
import { AttributeRow, AttributeType } from "./rows.js";
import type { AttributeRow, AttributeType } from "./rows.js";

interface SavingOpts {
skipValidation?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/bblob.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AbstractBeccaEntity from "./abstract_becca_entity.js";
import { BlobRow } from "./rows.js";
import type { BlobRow } from "./rows.js";

// TODO: Why this does not extend the abstract becca?
class BBlob extends AbstractBeccaEntity<BBlob> {
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/bbranch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import utils from "../../services/utils.js";
import TaskContext from "../../services/task_context.js";
import cls from "../../services/cls.js";
import log from "../../services/log.js";
import { BranchRow } from "./rows.js";
import type { BranchRow } from "./rows.js";
import handlers from "../../services/handlers.js";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/betapi_token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

import { EtapiTokenRow } from "./rows.js";
import type { EtapiTokenRow } from "./rows.js";

import dateUtils from "../../services/date_utils.js";
import AbstractBeccaEntity from "./abstract_becca_entity.js";
Expand Down
6 changes: 3 additions & 3 deletions src/becca/entities/bnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import TaskContext from "../../services/task_context.js";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js";
import eventService from "../../services/events.js";
import { AttachmentRow, AttributeType, NoteRow, NoteType, RevisionRow } from "./rows.js";
import type { AttachmentRow, AttributeType, NoteRow, NoteType, RevisionRow } from "./rows.js";
import BBranch from "./bbranch.js";
import BAttribute from "./battribute.js";
import { NotePojo } from "../becca-interface.js";
import type { NotePojo } from "../becca-interface.js";
import searchService from "../../services/search/services/search.js";
import cloningService, { CloneResponse } from "../../services/cloning.js";
import cloningService, { type CloneResponse } from "../../services/cloning.js";
import noteService from "../../services/notes.js";
import handlers from "../../services/handlers.js";
dayjs.extend(utc);
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/boption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import dateUtils from "../../services/date_utils.js";
import AbstractBeccaEntity from "./abstract_becca_entity.js";
import { OptionRow } from "./rows.js";
import type { OptionRow } from "./rows.js";

/**
* Option represents a name-value pair, either directly configurable by the user or some system property.
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/brecent_note.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

import { RecentNoteRow } from "./rows.js";
import type { RecentNoteRow } from "./rows.js";

import dateUtils from "../../services/date_utils.js";
import AbstractBeccaEntity from "./abstract_becca_entity.js";
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entities/brevision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import becca from "../becca.js";
import AbstractBeccaEntity from "./abstract_becca_entity.js";
import sql from "../../services/sql.js";
import BAttachment from "./battachment.js";
import { AttachmentRow, RevisionRow } from "./rows.js";
import type { AttachmentRow, RevisionRow } from "./rows.js";
import eraseService from "../../services/erase.js";

interface ContentOpts {
Expand Down
2 changes: 1 addition & 1 deletion src/becca/entity_constructor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConstructorData } from "./becca-interface.js";
import type { ConstructorData } from "./becca-interface.js";
import AbstractBeccaEntity from "./entities/abstract_becca_entity.js";
import BAttachment from "./entities/battachment.js";
import BAttribute from "./entities/battribute.js";
Expand Down
4 changes: 2 additions & 2 deletions src/etapi/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import mappers from "./mappers.js";
import v from "./validators.js";
import utils from "../services/utils.js";
import { Router } from "express";
import { AttachmentRow } from "../becca/entities/rows.js";
import { ValidatorMap } from "./etapi-interface.js";
import type { AttachmentRow } from "../becca/entities/rows.js";
import type { ValidatorMap } from "./etapi-interface.js";

function register(router: Router) {
const ALLOWED_PROPERTIES_FOR_CREATE_ATTACHMENT: ValidatorMap = {
Expand Down
4 changes: 2 additions & 2 deletions src/etapi/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import mappers from "./mappers.js";
import attributeService from "../services/attributes.js";
import v from "./validators.js";
import { Router } from "express";
import { AttributeRow } from "../becca/entities/rows.js";
import { ValidatorMap } from "./etapi-interface.js";
import type { AttributeRow } from "../becca/entities/rows.js";
import type { ValidatorMap } from "./etapi-interface.js";

function register(router: Router) {
eu.route(router, "get", "/etapi/attributes/:attributeId", (req, res, next) => {
Expand Down
2 changes: 1 addition & 1 deletion src/etapi/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import becca from "../becca/becca.js";
import eu from "./etapi_utils.js";
import passwordEncryptionService from "../services/encryption/password_encryption.js";
import etapiTokenService from "../services/etapi_tokens.js";
import { RequestHandler, Router } from "express";
import type { RequestHandler, Router } from "express";

function register(router: Router, loginMiddleware: RequestHandler[]) {
eu.NOT_AUTHENTICATED_ROUTE(router, "post", "/etapi/auth/login", loginMiddleware, (req, res, next) => {
Expand Down
2 changes: 1 addition & 1 deletion src/etapi/branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import mappers from "./mappers.js";
import BBranch from "../becca/entities/bbranch.js";
import entityChangesService from "../services/entity_changes.js";
import v from "./validators.js";
import { BranchRow } from "../becca/entities/rows.js";
import type { BranchRow } from "../becca/entities/rows.js";

function register(router: Router) {
eu.route(router, "get", "/etapi/branches/:branchId", (req, res, next) => {
Expand Down
6 changes: 3 additions & 3 deletions src/etapi/etapi_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import log from "../services/log.js";
import becca from "../becca/becca.js";
import etapiTokenService from "../services/etapi_tokens.js";
import config from "../services/config.js";
import { NextFunction, Request, RequestHandler, Response, Router } from "express";
import { ValidatorMap } from "./etapi-interface.js";
import { ApiRequestHandler } from "../routes/routes.js";
import type { NextFunction, Request, RequestHandler, Response, Router } from "express";
import type { ValidatorMap } from "./etapi-interface.js";
import type { ApiRequestHandler } from "../routes/routes.js";
const GENERIC_CODE = "GENERIC";

type HttpMethod = "all" | "get" | "post" | "put" | "delete" | "patch" | "options" | "head";
Expand Down
10 changes: 5 additions & 5 deletions src/etapi/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import searchService from "../services/search/services/search.js";
import SearchContext from "../services/search/search_context.js";
import zipExportService from "../services/export/zip.js";
import zipImportService from "../services/import/zip.js";
import { Request, Router } from "express";
import { ParsedQs } from "qs";
import { NoteParams } from "../services/note-interface.js";
import { SearchParams } from "../services/search/services/types.js";
import { ValidatorMap } from "./etapi-interface.js";
import { type Request, Router } from "express";
import type { ParsedQs } from "qs";
import type { NoteParams } from "../services/note-interface.js";
import type { SearchParams } from "../services/search/services/types.js";
import type { ValidatorMap } from "./etapi-interface.js";

function register(router: Router) {
eu.route(router, "get", "/etapi/notes", (req, res, next) => {
Expand Down
18 changes: 9 additions & 9 deletions src/public/app/components/app_context.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import froca from "../services/froca.js";
import bundleService from "../services/bundle.js";
import RootCommandExecutor from "./root_command_executor.js";
import Entrypoints, { SqlExecuteResults } from "./entrypoints.js";
import Entrypoints, { type SqlExecuteResults } from "./entrypoints.js";
import options from "../services/options.js";
import utils from "../services/utils.js";
import zoomComponent from "./zoom.js";
import TabManager from "./tab_manager.js";
import Component from "./component.js";
import keyboardActionsService from "../services/keyboard_actions.js";
import linkService, { ViewScope } from "../services/link.js";
import MobileScreenSwitcherExecutor, { Screen } from "./mobile_screen_switcher.js";
import linkService, { type ViewScope } from "../services/link.js";
import MobileScreenSwitcherExecutor, { type Screen } from "./mobile_screen_switcher.js";
import MainTreeExecutors from "./main_tree_executors.js";
import toast from "../services/toast.js";
import ShortcutComponent from "./shortcut_component.js";
import { t, initLocale } from "../services/i18n.js";
import NoteDetailWidget from "../widgets/note_detail.js";
import { ResolveOptions } from "../widgets/dialogs/delete_notes.js";
import { PromptDialogOptions } from "../widgets/dialogs/prompt.js";
import { ConfirmWithMessageOptions, ConfirmWithTitleOptions } from "../widgets/dialogs/confirm.js";
import { Node } from "../services/tree.js";
import type { ResolveOptions } from "../widgets/dialogs/delete_notes.js";
import type { PromptDialogOptions } from "../widgets/dialogs/prompt.js";
import type { ConfirmWithMessageOptions, ConfirmWithTitleOptions } from "../widgets/dialogs/confirm.js";
import type { Node } from "../services/tree.js";
import LoadResults from "../services/load_results.js";
import { Attribute } from "../services/attribute_parser.js";
import type { Attribute } from "../services/attribute_parser.js";
import NoteTreeWidget from "../widgets/note_tree.js";
import NoteContext, { GetTextEditorCallback } from "./note_context.js";
import NoteContext, { type GetTextEditorCallback } from "./note_context.js";

interface Layout {
getRootWidget: (appContext: AppContext) => RootWidget;
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/components/component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import utils from "../services/utils.js";
import { CommandMappings, CommandNames } from "./app_context.js";
import type { CommandMappings, CommandNames } from "./app_context.js";

/**
* Abstract class for all components in the Trilium's frontend.
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/components/entrypoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import utils from "../services/utils.js";
import dateNoteService from "../services/date_notes.js";
import protectedSessionHolder from "../services/protected_session_holder.js";
import server from "../services/server.js";
import appContext, { NoteCommandData } from "./app_context.js";
import appContext, { type NoteCommandData } from "./app_context.js";
import Component from "./component.js";
import toastService from "../services/toast.js";
import ws from "../services/ws.js";
Expand Down
4 changes: 2 additions & 2 deletions src/public/app/components/events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MenuCommandItem } from "../menus/context_menu.js";
import { CommandNames } from "./app_context.js";
import type { MenuCommandItem } from "../menus/context_menu.js";
import type { CommandNames } from "./app_context.js";

type ListenerReturnType = void | Promise<void>;

Expand Down
4 changes: 2 additions & 2 deletions src/public/app/components/note_context.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import protectedSessionHolder from "../services/protected_session_holder.js";
import server from "../services/server.js";
import utils from "../services/utils.js";
import appContext, { EventData, EventListener } from "./app_context.js";
import appContext, { type EventData, type EventListener } from "./app_context.js";
import treeService from "../services/tree.js";
import Component from "./component.js";
import froca from "../services/froca.js";
import hoistedNoteService from "../services/hoisted_note.js";
import options from "../services/options.js";
import { ViewScope } from "../services/link.js";
import type { ViewScope } from "../services/link.js";
import FNote from "../entities/fnote.js";

interface SetNoteOpts {
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/components/root_command_executor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from "./component.js";
import appContext, { CommandData, CommandListenerData } from "./app_context.js";
import appContext, { type CommandData, type CommandListenerData } from "./app_context.js";
import dateNoteService from "../services/date_notes.js";
import treeService from "../services/tree.js";
import openService from "../services/open.js";
Expand Down
4 changes: 2 additions & 2 deletions src/public/app/components/shortcut_component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import appContext, { EventData, EventListener } from "./app_context.js";
import appContext, { type EventData, type EventListener } from "./app_context.js";
import shortcutService from "../services/shortcuts.js";
import server from "../services/server.js";
import Component from "./component.js";
import froca from "../services/froca.js";
import { AttributeRow } from "../services/load_results.js";
import type { AttributeRow } from "../services/load_results.js";

export default class ShortcutComponent extends Component implements EventListener<"entitiesReloaded"> {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/entities/fattachment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Froca } from "../services/froca-interface.js";
import type { Froca } from "../services/froca-interface.js";

export interface FAttachmentRow {
attachmentId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/entities/fattribute.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Froca } from "../services/froca-interface.js";
import type { Froca } from "../services/froca-interface.js";
import promotedAttributeDefinitionParser from "../services/promoted_attribute_definition_parser.js";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/entities/fbranch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Froca } from "../services/froca-interface.js";
import type { Froca } from "../services/froca-interface.js";

export interface FBranchRow {
branchId: string;
Expand Down
4 changes: 2 additions & 2 deletions src/public/app/entities/fnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import ws from "../services/ws.js";
import froca from "../services/froca.js";
import protectedSessionHolder from "../services/protected_session_holder.js";
import cssClassManager from "../services/css_class_manager.js";
import { Froca } from "../services/froca-interface.js";
import type { Froca } from "../services/froca-interface.js";
import FAttachment from "./fattachment.js";
import FAttribute, { AttributeType } from "./fattribute.js";
import FAttribute, { type AttributeType } from "./fattribute.js";
import utils from "../services/utils.js";

const LABEL = "label";
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/menus/context_menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CommandNames } from "../components/app_context.js";
import type { CommandNames } from "../components/app_context.js";
import keyboardActionService from "../services/keyboard_actions.js";
import utils from "../services/utils.js";

Expand Down
4 changes: 2 additions & 2 deletions src/public/app/menus/electron_context_menu.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import utils from "../services/utils.js";
import options from "../services/options.js";
import zoomService from "../components/zoom.js";
import contextMenu, { MenuItem } from "./context_menu.js";
import contextMenu, { type MenuItem } from "./context_menu.js";
import { t } from "../services/i18n.js";
import type { BrowserWindow } from "electron";
import { CommandNames } from "../components/app_context.js";
import type { CommandNames } from "../components/app_context.js";

function setupContextMenu() {
const electron = utils.dynamicRequire("electron");
Expand Down
6 changes: 3 additions & 3 deletions src/public/app/menus/launcher_context_menu.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import treeService, { Node } from "../services/tree.js";
import treeService, { type Node } from "../services/tree.js";
import froca from "../services/froca.js";
import contextMenu, { MenuCommandItem, MenuItem } from "./context_menu.js";
import contextMenu, { type MenuCommandItem, type MenuItem } from "./context_menu.js";
import dialogService from "../services/dialog.js";
import server from "../services/server.js";
import { t } from "../services/i18n.js";
import type { SelectMenuItemEventListener } from "../components/events.js";
import NoteTreeWidget from "../widgets/note_tree.js";
import { FilteredCommandNames, ContextMenuCommandData } from "../components/app_context.js";
import type { FilteredCommandNames, ContextMenuCommandData } from "../components/app_context.js";

type LauncherCommandNames = FilteredCommandNames<ContextMenuCommandData>;

Expand Down
2 changes: 1 addition & 1 deletion src/public/app/menus/link_context_menu.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { t } from "../services/i18n.js";
import contextMenu from "./context_menu.js";
import appContext from "../components/app_context.js";
import { ViewScope } from "../services/link.js";
import type { ViewScope } from "../services/link.js";

function openContextMenu(notePath: string, e: PointerEvent, viewScope: ViewScope = {}, hoistedNoteId: string | null = null) {
contextMenu.show({
Expand Down
8 changes: 4 additions & 4 deletions src/public/app/menus/tree_context_menu.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import treeService, { Node } from "../services/tree.js";
import treeService, { type Node } from "../services/tree.js";
import froca from "../services/froca.js";
import clipboard from "../services/clipboard.js";
import noteCreateService from "../services/note_create.js";
import contextMenu, { MenuCommandItem, MenuItem } from "./context_menu.js";
import appContext, { ContextMenuCommandData, FilteredCommandNames } from "../components/app_context.js";
import contextMenu, { type MenuCommandItem, type MenuItem } from "./context_menu.js";
import appContext, { type ContextMenuCommandData, type FilteredCommandNames } from "../components/app_context.js";
import noteTypesService from "../services/note_types.js";
import server from "../services/server.js";
import toastService from "../services/toast.js";
import dialogService from "../services/dialog.js";
import { t } from "../services/i18n.js";
import NoteTreeWidget from "../widgets/note_tree.js";
import FAttachment from "../entities/fattachment.js";
import { SelectMenuItemEventListener } from "../components/events.js";
import type { SelectMenuItemEventListener } from "../components/events.js";

// TODO: Deduplicate once client/server is well split.
interface ConvertToAttachmentResponse {
Expand Down
Loading

0 comments on commit 324696b

Please sign in to comment.