orgnote-api 0.40.29 → 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 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: {
@@ -153,7 +153,9 @@ export declare enum i18n {
153
153
  AUTH_INVALID_CALLBACK_PARAMS = "invalid authentication callback parameters",
154
154
  AUTH_REMOVE_ACCOUNT_DESCRIPTION = "permanently delete your account",
155
155
  AUTH_GROUP = "auth",
156
- TABS_COUNT = "tabsCount"
156
+ TABS_COUNT = "tabsCount",
157
+ TOC_NO_ACTIVE_DOCUMENT = "no active document",
158
+ TOC_NO_HEADLINES_FOUND = "no headlines found"
157
159
  }
158
160
  export declare const I18N: {
159
161
  REPORT_BUG: DefaultCommands.REPORT_BUG;
@@ -241,6 +243,7 @@ export declare const I18N: {
241
243
  LOGIN: DefaultCommands.LOGIN;
242
244
  LOGOUT: DefaultCommands.LOGOUT;
243
245
  REMOVE_ACCOUNT: DefaultCommands.REMOVE_ACCOUNT;
246
+ INIT_SEARCH_INDEX: DefaultCommands.INIT_SEARCH_INDEX;
244
247
  LOADING: i18n.LOADING;
245
248
  LOADING_MESSAGE_1: i18n.LOADING_MESSAGE_1;
246
249
  LOADING_MESSAGE_2: i18n.LOADING_MESSAGE_2;
@@ -387,5 +390,7 @@ export declare const I18N: {
387
390
  AUTH_REMOVE_ACCOUNT_DESCRIPTION: i18n.AUTH_REMOVE_ACCOUNT_DESCRIPTION;
388
391
  AUTH_GROUP: i18n.AUTH_GROUP;
389
392
  TABS_COUNT: i18n.TABS_COUNT;
393
+ TOC_NO_ACTIVE_DOCUMENT: i18n.TOC_NO_ACTIVE_DOCUMENT;
394
+ TOC_NO_HEADLINES_FOUND: i18n.TOC_NO_HEADLINES_FOUND;
390
395
  };
391
396
  export type I18N = i18n | DefaultCommands;
@@ -162,6 +162,9 @@ export var i18n;
162
162
  i18n["AUTH_GROUP"] = "auth";
163
163
  // Tabs
164
164
  i18n["TABS_COUNT"] = "tabsCount";
165
+ // TOC
166
+ i18n["TOC_NO_ACTIVE_DOCUMENT"] = "no active document";
167
+ i18n["TOC_NO_HEADLINES_FOUND"] = "no headlines found";
165
168
  })(i18n || (i18n = {}));
166
169
  export const I18N = {
167
170
  ...i18n,
@@ -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({ ...testNote, encrypted: true }, {
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.title).toBe('Test note');
43
+ expect(decryptedNote.meta?.title).toBe('Test note');
54
44
  expect(decryptedText).toBe(noteText);
55
45
  });
@@ -1 +1 @@
1
- export * from './orgnode-to-note.js';
1
+ export * from './orgnode-to-file-meta.js';
package/mappers/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./orgnode-to-note.js";
1
+ export * from "./orgnode-to-file-meta.js";
@@ -0,0 +1,3 @@
1
+ import { OrgNode } from 'org-mode-ast';
2
+ import { DiskFile, FileMeta } from "../models/index.js";
3
+ export declare function orgnodeToFileMeta(orgnode: OrgNode, fileInfo: DiskFile): FileMeta;
@@ -1,9 +1,10 @@
1
1
  import { splitPath } from "../utils/index.js";
2
- export function orgnodeToNoteInfo(orgnode, fileInfo, isMy) {
2
+ export function orgnodeToFileMeta(orgnode, fileInfo) {
3
3
  return {
4
- id: orgnode.meta.id,
5
- isMy,
6
- meta: orgnode.meta,
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(),
@@ -83,5 +83,6 @@ export declare enum DefaultCommands {
83
83
  OPEN_EXTENSIONS_MANAGER = "open extensions manager",
84
84
  LOGIN = "login",
85
85
  LOGOUT = "logout",
86
- REMOVE_ACCOUNT = "remove account"
86
+ REMOVE_ACCOUNT = "remove account",
87
+ INIT_SEARCH_INDEX = "init search index"
87
88
  }
@@ -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 './note.js';
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 "./note.js";
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";
@@ -1,9 +1,7 @@
1
1
  import { ExtensionSource } from './extension.js';
2
- import { FileInfo } from './file-info.js';
3
- import { FilePathInfo } from './file-path.js';
2
+ import { FileMeta } from './file-meta.js';
4
3
  import { LayoutSnapshotRepository } from './layout-snapshot-repository.js';
5
4
  import { LoggerRepository } from './log-repository.js';
6
- import { NoteInfo } from './note.js';
7
5
  import { QueueTask } from './queue-task.js';
8
6
  export interface ExtensionSourceRepository {
9
7
  get(extensionName: string): Promise<ExtensionSource | undefined>;
@@ -15,52 +13,23 @@ export interface ExtensionSourceRepository {
15
13
  deleteBySource(source: string): Promise<void>;
16
14
  clear(): Promise<void>;
17
15
  }
18
- export interface FileInfoRepository {
19
- upsert(file: FileInfo): Promise<void>;
20
- bulkUpsert(file: FileInfo[]): Promise<void>;
21
- update(filePath: string, file: Partial<FileInfo>): Promise<void>;
22
- delete(filePath: string): Promise<void>;
23
- markAsDelete(filePath: string, deletedAt?: Date): Promise<void>;
24
- clear(): Promise<void>;
25
- search(text: string): Promise<FileInfo[]>;
26
- getByPath(path: string): Promise<FileInfo | undefined>;
27
- getAll(): Promise<FileInfo[]>;
28
- getFilesAfterUpdateTime(updatedTime?: Date): Promise<FileInfo[]>;
29
- count(updatedTime?: Date): Promise<number>;
30
- }
31
- export interface NoteInfoRepository {
32
- getNotesAfterUpdateTime(updatedTime?: string): Promise<NoteInfo[]>;
33
- getDeletedNotes(): Promise<NoteInfo[]>;
34
- saveNotes(notes: NoteInfo[]): Promise<void>;
35
- putNote(note: NoteInfo): Promise<void>;
36
- getById(id: string): Promise<NoteInfo | undefined>;
37
- getByPath(path: string[]): Promise<NoteInfo | undefined>;
38
- 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?: {
39
21
  limit?: number;
40
22
  offset?: number;
41
- searchText?: string;
42
23
  tags?: string[];
43
- bookmarked?: boolean;
44
- }): Promise<NoteInfo[]>;
45
- deleteNotes(noteIds: string[]): Promise<void>;
46
- markAsDeleted(noteIds: string[]): Promise<void>;
47
- bulkPartialUpdate(updates: {
48
- id: string;
49
- changes: Partial<NoteInfo>;
50
- }[]): Promise<void>;
51
- count(searchText?: string, tags?: string[]): Promise<number>;
52
- getFilePaths(): Promise<FilePathInfo[]>;
53
- touchNote(noteId: string): Promise<void>;
54
- 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<{
55
30
  tag: string;
56
31
  count: number;
57
32
  }[]>;
58
- addBookmark(noteId: string): Promise<void>;
59
- deleteBookmark(noteId: string): Promise<void>;
60
- modify(modifyCallback: (note: NoteInfo, ref: {
61
- value: NoteInfo;
62
- }) => void): Promise<void>;
63
- getIds(filterCb?: (n: NoteInfo) => boolean): Promise<string[]>;
64
33
  clear(): Promise<void>;
65
34
  }
66
35
  export interface QueueRepository {
@@ -80,11 +49,17 @@ export interface QueueRepository {
80
49
  clear(queueId: string): Promise<void>;
81
50
  setStatus: (id: string, status: string) => Promise<void>;
82
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
+ }
83
58
  export interface Repositories {
84
59
  logRepository: LoggerRepository;
85
- fileInfoRepository: FileInfoRepository;
86
- noteInfoRepository: NoteInfoRepository;
87
60
  layoutSnapshotRepository: LayoutSnapshotRepository;
88
61
  queueRepository: QueueRepository;
89
62
  extensionSourceRepository: ExtensionSourceRepository;
63
+ keyValueRepository: KeyValueRepository;
64
+ fileRepository: FileRepository;
90
65
  }
package/models/user.d.ts CHANGED
@@ -1,4 +1,11 @@
1
1
  import { ModelsUserPersonalInfo } from "../remote-api/index.js";
2
- import { PublicUser } from './note.js';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.40.29",
3
+ "version": "0.40.32",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -1,3 +0,0 @@
1
- import { OrgNode } from 'org-mode-ast';
2
- import { DiskFile, NoteInfo } from "../models/index.js";
3
- export declare function orgnodeToNoteInfo(orgnode: OrgNode, fileInfo: DiskFile, isMy?: boolean): NoteInfo;
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