Skip to content

Commit 74a1657

Browse files
Jakob Schlanstedtwerererer
authored andcommitted
refactor(create_note): rename types to fit ontological concepts better
1 parent 591bb72 commit 74a1657

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

apps/client/src/components/app_context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import TouchBarComponent from "./touch_bar.js";
2828
import type { CKTextEditor } from "@triliumnext/ckeditor5";
2929
import type CodeMirror from "@triliumnext/codemirror";
3030
import { StartupChecks } from "./startup_checks.js";
31-
import type { BaseCreateNoteOpts } from "../services/note_create.js";
31+
import type { CreateNoteOpts } from "../services/note_create.js";
3232
import { ColumnComponent } from "tabulator-tables";
3333
import { ChooseNoteTypeCallback } from "../widgets/dialogs/note_type_chooser.jsx";
3434
import type RootContainer from "../widgets/containers/root_container.js";
@@ -357,7 +357,7 @@ export type CommandMappings = {
357357

358358
// Table view
359359
addNewRow: CommandData & {
360-
customOpts: BaseCreateNoteOpts;
360+
customOpts: CreateNoteOpts;
361361
parentNotePath?: string;
362362
};
363363
addNewTableColumn: CommandData & {

apps/client/src/services/note_create.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import dateNoteService from "../services/date_notes.js";
2929
*
3030
* * Hierarchy of general to specific categories(hypernyms -> hyponyms):
3131
*
32-
* * BaseCreateNoteSharedOpts
32+
* * CreateNoteEntity
3333
* |
34-
* \-- BaseCreateNoteOpts
34+
* \-- CreateNoteOpts
3535
* |
3636
* +-- CreateNoteAtUrlOpts
3737
* | +-- CreateNoteIntoURLOpts
@@ -46,7 +46,7 @@ import dateNoteService from "../services/date_notes.js";
4646
* this is the shared basis for all types. Every other type is child (hyponym)
4747
* of it (domain hypernym).
4848
*/
49-
type BaseCreateNoteSharedOpts = {
49+
type CreateNoteEntity = {
5050
target: CreateNoteTarget;
5151
isProtected?: boolean;
5252
saveSelection?: boolean;
@@ -60,12 +60,12 @@ type BaseCreateNoteSharedOpts = {
6060
textEditor?: CKTextEditor;
6161
}
6262

63-
export type BaseCreateNoteOpts =
64-
| (BaseCreateNoteSharedOpts & {
63+
export type CreateNoteOpts =
64+
| (CreateNoteEntity & {
6565
promptForType: true;
6666
type?: never;
6767
})
68-
| (BaseCreateNoteSharedOpts & {
68+
| (CreateNoteEntity & {
6969
promptForType?: false;
7070
type?: string;
7171
});
@@ -75,7 +75,7 @@ export type BaseCreateNoteOpts =
7575
* of "into" and "as siblings". It is not exported because it only exists, to
7676
* have its legal values propagated to its children (types inheriting from it).
7777
*/
78-
type CreateNoteAtUrlOpts = BaseCreateNoteOpts & {
78+
type CreateNoteAtUrlOpts = CreateNoteOpts & {
7979
// `Url` means either parentNotePath or parentNoteId.
8080
// The vocabulary is inspired by its loose semantics of getNoteIdFromUrl.
8181
parentNoteUrl: string;
@@ -92,7 +92,7 @@ type CreateNoteSiblingURLOpts = CreateNoteAtUrlOpts;
9292
export type CreateNoteBeforeURLOpts = CreateNoteSiblingURLOpts;
9393
export type CreateNoteAfterURLOpts = CreateNoteSiblingURLOpts;
9494

95-
export type CreateNoteIntoInboxURLOpts = BaseCreateNoteOpts & {
95+
export type CreateNoteIntoInboxURLOpts = CreateNoteOpts & {
9696
parentNoteUrl?: never;
9797
}
9898

@@ -132,7 +132,7 @@ async function createNote(
132132
): Promise<{ note: FNote | null; branch: FBranch | undefined }>;
133133

134134
async function createNote(
135-
options: BaseCreateNoteOpts
135+
options: CreateNoteOpts
136136
): Promise<{ note: FNote | null; branch: FBranch | undefined }> {
137137

138138
let resolvedOptions = { ...options };
@@ -150,7 +150,7 @@ async function createNote(
150150
promptForType: false,
151151
type: noteType,
152152
templateNoteId,
153-
} as BaseCreateNoteOpts;
153+
} as CreateNoteOpts;
154154

155155
if (notePath) {
156156
resolvedOptions = resolvedOptions as CreateNoteIntoURLOpts;
@@ -187,7 +187,7 @@ async function createNote(
187187
* Core function that creates a new note under the specified parent note path.
188188
*
189189
* @param target - Duplicates apps/server/src/routes/api/notes.ts createNote
190-
* @param {BaseCreateNoteSharedOpts} [options] - Options controlling note creation (title, content, type, template, focus, etc.).
190+
* @param {CreateNoteEntity} [options] - Options controlling note creation (title, content, type, template, focus, etc.).
191191
* with parentNotePath - The parent note path where the new note will be created.
192192
* @returns {Promise<{ note: FNote | null; branch: FBranch | undefined }>}
193193
* Resolves with the created note and branch entities.
@@ -290,7 +290,7 @@ async function createNoteAfterNote(
290290
/**
291291
* Creates a new note inside the user's Inbox.
292292
*
293-
* @param {BaseCreateNoteSharedOpts} [options] - Optional settings such as title, type, template, or content.
293+
* @param {CreateNoteEntity} [options] - Optional settings such as title, type, template, or content.
294294
* @returns {Promise<{ note: FNote | null; branch: FBranch | undefined }>}
295295
* Resolves with the created note and its branch, or `{ note: null, branch: undefined }` if the inbox is missing.
296296
*/

apps/client/src/widgets/collections/table/row_editing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventCallBackMethods, RowComponent, Tabulator } from "tabulator-tables";
22
import { CommandListenerData } from "../../../components/app_context";
3-
import note_create, { BaseCreateNoteOpts, CreateNoteIntoURLOpts as CreateNoteIntoURLOpts, CreateNoteTarget } from "../../../services/note_create";
3+
import note_create, { CreateNoteOpts, CreateNoteIntoURLOpts as CreateNoteIntoURLOpts, CreateNoteTarget } from "../../../services/note_create";
44
import { useLegacyImperativeHandlers } from "../../react/hooks";
55
import { RefObject } from "preact";
66
import { setAttribute, setLabel } from "../../../services/attributes";
@@ -15,7 +15,7 @@ export default function useRowTableEditing(api: RefObject<Tabulator>, attributeD
1515
addNewRowCommand({ customOpts, parentNotePath: customNotePath }: CommandListenerData<"addNewRow">) {
1616
const notePath = customNotePath ?? parentNotePath;
1717
if (notePath) {
18-
const opts: BaseCreateNoteOpts = {
18+
const opts: CreateNoteOpts = {
1919
activate: false,
2020
...customOpts
2121
}

0 commit comments

Comments
 (0)