orgnote-api 0.40.31 → 0.40.32
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/api.d.ts +3 -1
- package/constants/i18n-keys.d.ts +1 -0
- package/encryption/__tests__/note-encryption.spec.js +2 -12
- package/mappers/index.d.ts +1 -1
- package/mappers/index.js +1 -1
- package/mappers/orgnode-to-file-meta.d.ts +3 -0
- package/mappers/{orgnode-to-note.js → orgnode-to-file-meta.js} +5 -4
- package/models/default-commands.d.ts +2 -1
- package/models/default-commands.js +2 -0
- package/models/encryption-store.d.ts +0 -3
- package/models/file-meta-store.d.ts +26 -0
- package/models/file-meta.d.ts +18 -0
- package/models/file-meta.js +1 -0
- package/models/file-search-store.d.ts +35 -0
- package/models/file-search-store.js +1 -0
- package/models/index.d.ts +3 -1
- package/models/index.js +3 -1
- package/models/repositories.d.ts +20 -30
- package/models/user.d.ts +8 -1
- package/package.json +1 -1
- package/mappers/orgnode-to-note.d.ts +0 -3
- package/models/note.d.ts +0 -40
- /package/models/{note.js → file-meta-store.js} +0 -0
package/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InlineEmbeddedWidget, MultilineEmbeddedWidget, OrgLineClass, SyncStoreDefinition, FileReaderStoreDefinition, CommandsStoreDefinition, CommandsGroupStoreDefinition, ModalStoreDefinition, SettingsStoreDefinition, SettingsUiStoreDefinition, MultipleUploadParams, UploadParams, CompletionStoreDefinition, PaneStoreDefinition, LayoutStoreDefinition, FileManagerStoreDefinition, UseScreenDetection, NotificationsStoreDefinition, BufferStoreDefinition, Repositories, LogStoreDefinition, UseSystemInfo, ContextMenuStoreDefinition, QueueStoreDefinition, FileGuardStoreDefinition, FileWatcherStoreDefinition, BuildOrgNoteUrl, AuthStoreDefinition } from './models/index.js';
|
|
1
|
+
import { InlineEmbeddedWidget, MultilineEmbeddedWidget, OrgLineClass, SyncStoreDefinition, FileReaderStoreDefinition, CommandsStoreDefinition, CommandsGroupStoreDefinition, ModalStoreDefinition, SettingsStoreDefinition, SettingsUiStoreDefinition, MultipleUploadParams, UploadParams, CompletionStoreDefinition, PaneStoreDefinition, LayoutStoreDefinition, FileManagerStoreDefinition, UseScreenDetection, NotificationsStoreDefinition, BufferStoreDefinition, Repositories, LogStoreDefinition, UseSystemInfo, ContextMenuStoreDefinition, QueueStoreDefinition, FileGuardStoreDefinition, FileWatcherStoreDefinition, BuildOrgNoteUrl, AuthStoreDefinition, FileSearchStoreDefinition, FileMetaStoreDefinition } from './models/index.js';
|
|
2
2
|
import { WebSocketClient } from './websocket/client.js';
|
|
3
3
|
import { WidgetType } from './models/widget-type.js';
|
|
4
4
|
import { NodeType } from 'org-mode-ast';
|
|
@@ -72,6 +72,8 @@ export interface OrgNoteApi {
|
|
|
72
72
|
useSync: SyncStoreDefinition;
|
|
73
73
|
useEditor: EditorStoreDefinition;
|
|
74
74
|
useBabel: BabelStoreDefinition;
|
|
75
|
+
useFileSearch: FileSearchStoreDefinition;
|
|
76
|
+
useFileMeta: FileMetaStoreDefinition;
|
|
75
77
|
app: App;
|
|
76
78
|
};
|
|
77
79
|
utils: {
|
package/constants/i18n-keys.d.ts
CHANGED
|
@@ -243,6 +243,7 @@ export declare const I18N: {
|
|
|
243
243
|
LOGIN: DefaultCommands.LOGIN;
|
|
244
244
|
LOGOUT: DefaultCommands.LOGOUT;
|
|
245
245
|
REMOVE_ACCOUNT: DefaultCommands.REMOVE_ACCOUNT;
|
|
246
|
+
INIT_SEARCH_INDEX: DefaultCommands.INIT_SEARCH_INDEX;
|
|
246
247
|
LOADING: i18n.LOADING;
|
|
247
248
|
LOADING_MESSAGE_1: i18n.LOADING_MESSAGE_1;
|
|
248
249
|
LOADING_MESSAGE_2: i18n.LOADING_MESSAGE_2;
|
|
@@ -8,13 +8,6 @@ const testNote = {
|
|
|
8
8
|
title: 'Test note',
|
|
9
9
|
published: false,
|
|
10
10
|
},
|
|
11
|
-
createdAt: '2024-01-01T00:00:00.000Z',
|
|
12
|
-
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
13
|
-
touchedAt: '2024-01-01T00:00:00.000Z',
|
|
14
|
-
filePath: ['/test/note.org'],
|
|
15
|
-
isMy: true,
|
|
16
|
-
bookmarked: false,
|
|
17
|
-
encrypted: false,
|
|
18
11
|
};
|
|
19
12
|
test('Should encrypt note via keys', async () => {
|
|
20
13
|
const noteText = '#+title: Test note\n\nBody text';
|
|
@@ -27,9 +20,7 @@ test('Should encrypt note via keys', async () => {
|
|
|
27
20
|
format: 'armored',
|
|
28
21
|
});
|
|
29
22
|
expect(encryptedNoteText.startsWith('-----BEGIN PGP MESSAGE-----')).toBe(true);
|
|
30
|
-
expect(encryptedNote.encrypted).toBe(true);
|
|
31
23
|
expect(encryptedNote.id).toBe(testNote.id);
|
|
32
|
-
expect(encryptedNote.meta.id).toBeUndefined();
|
|
33
24
|
});
|
|
34
25
|
test('Should decrypt note via keys', async () => {
|
|
35
26
|
const noteText = '#+title: Test note\n\nBody text';
|
|
@@ -41,15 +32,14 @@ test('Should decrypt note via keys', async () => {
|
|
|
41
32
|
privateKeyPassphrase,
|
|
42
33
|
format: 'armored',
|
|
43
34
|
});
|
|
44
|
-
const [decryptedNote, decryptedText] = await decryptNote(
|
|
35
|
+
const [decryptedNote, decryptedText] = await decryptNote(testNote, {
|
|
45
36
|
content: encryptedNoteText,
|
|
46
37
|
type: EncryptionType.GpgKeys,
|
|
47
38
|
publicKey: armoredPublicKey,
|
|
48
39
|
privateKey: armoredPrivateKey,
|
|
49
40
|
privateKeyPassphrase,
|
|
50
41
|
});
|
|
51
|
-
expect(decryptedNote.encrypted).toBe(false);
|
|
52
42
|
expect(decryptedNote.id).toBe(testNote.id);
|
|
53
|
-
expect(decryptedNote.meta
|
|
43
|
+
expect(decryptedNote.meta?.title).toBe('Test note');
|
|
54
44
|
expect(decryptedText).toBe(noteText);
|
|
55
45
|
});
|
package/mappers/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './orgnode-to-
|
|
1
|
+
export * from './orgnode-to-file-meta.js';
|
package/mappers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./orgnode-to-
|
|
1
|
+
export * from "./orgnode-to-file-meta.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { splitPath } from "../utils/index.js";
|
|
2
|
-
export function
|
|
2
|
+
export function orgnodeToFileMeta(orgnode, fileInfo) {
|
|
3
3
|
return {
|
|
4
|
-
id: orgnode.meta.id,
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
id: orgnode.meta.id ?? '',
|
|
5
|
+
title: orgnode.meta.title,
|
|
6
|
+
description: orgnode.meta.description,
|
|
7
|
+
tags: orgnode.meta.fileTags,
|
|
7
8
|
filePath: splitPath(fileInfo.path),
|
|
8
9
|
touchedAt: fileInfo.atime && new Date(fileInfo.atime).toISOString(),
|
|
9
10
|
updatedAt: new Date(Math.max(fileInfo.mtime, fileInfo.ctime)).toISOString(),
|
|
@@ -105,4 +105,6 @@ export var DefaultCommands;
|
|
|
105
105
|
DefaultCommands["LOGIN"] = "login";
|
|
106
106
|
DefaultCommands["LOGOUT"] = "logout";
|
|
107
107
|
DefaultCommands["REMOVE_ACCOUNT"] = "remove account";
|
|
108
|
+
// Search
|
|
109
|
+
DefaultCommands["INIT_SEARCH_INDEX"] = "init search index";
|
|
108
110
|
})(DefaultCommands || (DefaultCommands = {}));
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { BaseOrgNoteEncryption, OrgNoteEncryption, BaseOrgNoteDecryption } from './encryption.js';
|
|
2
|
-
import { NoteInfo } from './note.js';
|
|
3
2
|
import { StoreDefinition } from './store.js';
|
|
4
3
|
export interface EncryptionStore {
|
|
5
4
|
encrypt: (text: string, format?: BaseOrgNoteEncryption['format'], encryptionConfig?: OrgNoteEncryption) => Promise<string>;
|
|
6
5
|
decrypt: (content: string | Uint8Array, format?: BaseOrgNoteDecryption['format'], encryptionConfig?: OrgNoteEncryption) => Promise<string>;
|
|
7
|
-
encryptNote: (noteInfo: NoteInfo, noteText: string) => Promise<[NoteInfo, string]>;
|
|
8
|
-
decryptNote: (noteInfo: NoteInfo, noteText: string) => Promise<[NoteInfo, string | Uint8Array]>;
|
|
9
6
|
}
|
|
10
7
|
export type EncryptionStoreDefinition = StoreDefinition<EncryptionStore>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FileMeta } from './file-meta.js';
|
|
2
|
+
import type { StoreDefinition } from './store.js';
|
|
3
|
+
export interface FileMetaStore {
|
|
4
|
+
getById(id: string): Promise<FileMeta | undefined>;
|
|
5
|
+
getByIds(ids: string[]): Promise<FileMeta[]>;
|
|
6
|
+
getByPath(filePath: string[]): Promise<FileMeta | undefined>;
|
|
7
|
+
getAll(options?: {
|
|
8
|
+
limit?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
}): Promise<FileMeta[]>;
|
|
12
|
+
count(tags?: string[]): Promise<number>;
|
|
13
|
+
getTagsStats(): Promise<{
|
|
14
|
+
tag: string;
|
|
15
|
+
count: number;
|
|
16
|
+
}[]>;
|
|
17
|
+
save(meta: FileMeta): Promise<void>;
|
|
18
|
+
saveBulk(metas: FileMeta[]): Promise<void>;
|
|
19
|
+
delete(target: {
|
|
20
|
+
id: string;
|
|
21
|
+
} | {
|
|
22
|
+
path: string[];
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
clear(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export type FileMetaStoreDefinition = StoreDefinition<FileMetaStore>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface FileMetaFilter {
|
|
2
|
+
limit?: number;
|
|
3
|
+
offset?: number;
|
|
4
|
+
tags?: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface FileMeta {
|
|
7
|
+
id: string;
|
|
8
|
+
filePath: string[];
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
tags?: string[];
|
|
12
|
+
links?: string[];
|
|
13
|
+
backlinks?: string[];
|
|
14
|
+
createdAt?: string;
|
|
15
|
+
updatedAt?: string;
|
|
16
|
+
touchedAt?: string;
|
|
17
|
+
deletedAt?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Ref, ComputedRef } from 'vue';
|
|
2
|
+
import type { FileMeta } from './file-meta.js';
|
|
3
|
+
import type { StoreDefinition } from './store.js';
|
|
4
|
+
export interface FileSearchResult {
|
|
5
|
+
files: FileMeta[];
|
|
6
|
+
total: number;
|
|
7
|
+
query: string;
|
|
8
|
+
searchedAt: number;
|
|
9
|
+
}
|
|
10
|
+
export interface FileIndexStats {
|
|
11
|
+
indexed: number;
|
|
12
|
+
total: number;
|
|
13
|
+
}
|
|
14
|
+
export interface FileSearchStore {
|
|
15
|
+
isSearching: Ref<boolean>;
|
|
16
|
+
isIndexing: Ref<boolean>;
|
|
17
|
+
lastSearchResult: Ref<FileSearchResult | null>;
|
|
18
|
+
indexStats: ComputedRef<FileIndexStats>;
|
|
19
|
+
search(query: string, options?: {
|
|
20
|
+
limit?: number;
|
|
21
|
+
offset?: number;
|
|
22
|
+
}): Promise<FileMeta[]>;
|
|
23
|
+
indexFile(filePath: string): Promise<void>;
|
|
24
|
+
indexFiles(): Promise<void>;
|
|
25
|
+
processFile(filePath: string): Promise<void>;
|
|
26
|
+
removeFile(target: {
|
|
27
|
+
id: string;
|
|
28
|
+
} | {
|
|
29
|
+
path: string[];
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
loadIndex(): Promise<boolean>;
|
|
32
|
+
saveIndex(): Promise<void>;
|
|
33
|
+
clearIndex(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export type FileSearchStoreDefinition = StoreDefinition<FileSearchStore>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/models/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './file-meta.js';
|
|
2
2
|
export * from './command.js';
|
|
3
3
|
export * from './completion.js';
|
|
4
4
|
export * from './extension.js';
|
|
@@ -76,6 +76,8 @@ export * from './cron-store.js';
|
|
|
76
76
|
export * from './git-store.js';
|
|
77
77
|
export * from './extension-registry-store.js';
|
|
78
78
|
export * from './theme-store.js';
|
|
79
|
+
export * from './file-search-store.js';
|
|
80
|
+
export * from './file-meta-store.js';
|
|
79
81
|
export * from './style-variant.js';
|
|
80
82
|
export * from './style-size.js';
|
|
81
83
|
export * from './repositories.js';
|
package/models/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./file-meta.js";
|
|
2
2
|
export * from "./command.js";
|
|
3
3
|
export * from "./completion.js";
|
|
4
4
|
export * from "./extension.js";
|
|
@@ -78,6 +78,8 @@ export * from "./cron-store.js";
|
|
|
78
78
|
export * from "./git-store.js";
|
|
79
79
|
export * from "./extension-registry-store.js";
|
|
80
80
|
export * from "./theme-store.js";
|
|
81
|
+
export * from "./file-search-store.js";
|
|
82
|
+
export * from "./file-meta-store.js";
|
|
81
83
|
// UI
|
|
82
84
|
export * from "./style-variant.js";
|
|
83
85
|
export * from "./style-size.js";
|
package/models/repositories.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ExtensionSource } from './extension.js';
|
|
2
|
-
import {
|
|
2
|
+
import { FileMeta } from './file-meta.js';
|
|
3
3
|
import { LayoutSnapshotRepository } from './layout-snapshot-repository.js';
|
|
4
4
|
import { LoggerRepository } from './log-repository.js';
|
|
5
|
-
import { NoteInfo } from './note.js';
|
|
6
5
|
import { QueueTask } from './queue-task.js';
|
|
7
6
|
export interface ExtensionSourceRepository {
|
|
8
7
|
get(extensionName: string): Promise<ExtensionSource | undefined>;
|
|
@@ -14,39 +13,23 @@ export interface ExtensionSourceRepository {
|
|
|
14
13
|
deleteBySource(source: string): Promise<void>;
|
|
15
14
|
clear(): Promise<void>;
|
|
16
15
|
}
|
|
17
|
-
export interface
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
getById(id: string): Promise<NoteInfo | undefined>;
|
|
23
|
-
getByPath(path: string[]): Promise<NoteInfo | undefined>;
|
|
24
|
-
getNotesInfo(options?: {
|
|
16
|
+
export interface FileRepository {
|
|
17
|
+
getById(id: string): Promise<FileMeta | undefined>;
|
|
18
|
+
getByIds(ids: string[]): Promise<FileMeta[]>;
|
|
19
|
+
getByPath(filePath: string[]): Promise<FileMeta | undefined>;
|
|
20
|
+
getAll(options?: {
|
|
25
21
|
limit?: number;
|
|
26
22
|
offset?: number;
|
|
27
|
-
searchText?: string;
|
|
28
23
|
tags?: string[];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
changes: Partial<NoteInfo>;
|
|
36
|
-
}[]): Promise<void>;
|
|
37
|
-
count(searchText?: string, tags?: string[]): Promise<number>;
|
|
38
|
-
getFilePaths(): Promise<FilePathInfo[]>;
|
|
39
|
-
touchNote(noteId: string): Promise<void>;
|
|
40
|
-
getTagsStatistic(): Promise<{
|
|
24
|
+
}): Promise<FileMeta[]>;
|
|
25
|
+
save(meta: FileMeta): Promise<void>;
|
|
26
|
+
saveBulk(metas: FileMeta[]): Promise<void>;
|
|
27
|
+
delete(id: string): Promise<void>;
|
|
28
|
+
count(tags?: string[]): Promise<number>;
|
|
29
|
+
getTagsStats(): Promise<{
|
|
41
30
|
tag: string;
|
|
42
31
|
count: number;
|
|
43
32
|
}[]>;
|
|
44
|
-
addBookmark(noteId: string): Promise<void>;
|
|
45
|
-
deleteBookmark(noteId: string): Promise<void>;
|
|
46
|
-
modify(modifyCallback: (note: NoteInfo, ref: {
|
|
47
|
-
value: NoteInfo;
|
|
48
|
-
}) => void): Promise<void>;
|
|
49
|
-
getIds(filterCb?: (n: NoteInfo) => boolean): Promise<string[]>;
|
|
50
33
|
clear(): Promise<void>;
|
|
51
34
|
}
|
|
52
35
|
export interface QueueRepository {
|
|
@@ -66,10 +49,17 @@ export interface QueueRepository {
|
|
|
66
49
|
clear(queueId: string): Promise<void>;
|
|
67
50
|
setStatus: (id: string, status: string) => Promise<void>;
|
|
68
51
|
}
|
|
52
|
+
export interface KeyValueRepository {
|
|
53
|
+
get(key: string): Promise<string | undefined>;
|
|
54
|
+
set(key: string, value: string): Promise<void>;
|
|
55
|
+
delete(key: string): Promise<void>;
|
|
56
|
+
clear(): Promise<void>;
|
|
57
|
+
}
|
|
69
58
|
export interface Repositories {
|
|
70
59
|
logRepository: LoggerRepository;
|
|
71
|
-
noteInfoRepository: NoteInfoRepository;
|
|
72
60
|
layoutSnapshotRepository: LayoutSnapshotRepository;
|
|
73
61
|
queueRepository: QueueRepository;
|
|
74
62
|
extensionSourceRepository: ExtensionSourceRepository;
|
|
63
|
+
keyValueRepository: KeyValueRepository;
|
|
64
|
+
fileRepository: FileRepository;
|
|
75
65
|
}
|
package/models/user.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ModelsUserPersonalInfo } from "../remote-api/index.js";
|
|
2
|
-
|
|
2
|
+
export interface PublicUser {
|
|
3
|
+
id?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
nickName?: string;
|
|
6
|
+
avatarUrl?: string;
|
|
7
|
+
email?: string;
|
|
8
|
+
profileUrl?: string;
|
|
9
|
+
}
|
|
3
10
|
export type User = PublicUser;
|
|
4
11
|
export type PersonalInfo = ModelsUserPersonalInfo;
|
package/package.json
CHANGED
package/models/note.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { EncryptionType } from './encryption.js';
|
|
2
|
-
export interface NotesFilter {
|
|
3
|
-
searchText?: string;
|
|
4
|
-
userId?: string;
|
|
5
|
-
limit?: number;
|
|
6
|
-
offset?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface NoteMeta {
|
|
9
|
-
id?: string;
|
|
10
|
-
title?: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
fileTags?: string[];
|
|
13
|
-
previewImg?: string;
|
|
14
|
-
published?: boolean;
|
|
15
|
-
startup?: string;
|
|
16
|
-
images?: string[];
|
|
17
|
-
connectedNotes?: Record<string, string>;
|
|
18
|
-
}
|
|
19
|
-
export interface PublicUser {
|
|
20
|
-
id?: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
nickName?: string;
|
|
23
|
-
avatarUrl?: string;
|
|
24
|
-
email?: string;
|
|
25
|
-
profileUrl?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface NoteInfo {
|
|
28
|
-
id?: string;
|
|
29
|
-
meta: NoteMeta;
|
|
30
|
-
createdAt?: string;
|
|
31
|
-
encryptionType?: EncryptionType;
|
|
32
|
-
updatedAt?: string;
|
|
33
|
-
touchedAt?: string;
|
|
34
|
-
deletedAt?: string;
|
|
35
|
-
filePath?: string[];
|
|
36
|
-
isMy?: boolean;
|
|
37
|
-
author?: PublicUser;
|
|
38
|
-
bookmarked?: boolean;
|
|
39
|
-
encrypted?: boolean;
|
|
40
|
-
}
|
|
File without changes
|