orgnote-api 0.18.1 → 0.19.0

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.
Files changed (44) hide show
  1. package/api.d.ts +9 -3
  2. package/encryption/__tests__/encryption.spec.js +56 -1
  3. package/mappers/orgnode-to-note.js +2 -2
  4. package/models/auth-store.d.ts +21 -0
  5. package/models/auth-store.js +1 -0
  6. package/models/command.d.ts +1 -2
  7. package/models/default-commands.d.ts +4 -1
  8. package/models/default-commands.js +4 -0
  9. package/models/file-cache.d.ts +12 -0
  10. package/models/file-cache.js +1 -0
  11. package/models/file-manager-store.d.ts +14 -0
  12. package/models/file-manager-store.js +1 -0
  13. package/models/file-opener-store.d.ts +5 -0
  14. package/models/file-opener-store.js +1 -0
  15. package/models/file-path.d.ts +4 -0
  16. package/models/file-path.js +1 -0
  17. package/models/file-system-store.d.ts +0 -0
  18. package/models/file-system-store.js +0 -0
  19. package/models/file-system.d.ts +2 -1
  20. package/models/file-tree.d.ts +12 -0
  21. package/models/file-tree.js +1 -0
  22. package/models/files-store.d.ts +6 -0
  23. package/models/files-store.js +1 -0
  24. package/models/index.d.ts +11 -0
  25. package/models/index.js +13 -0
  26. package/models/oauth-provider.d.ts +1 -0
  27. package/models/oauth-provider.js +1 -0
  28. package/models/repositories.d.ts +70 -0
  29. package/models/repositories.js +1 -0
  30. package/models/store.d.ts +2 -0
  31. package/models/store.js +1 -0
  32. package/models/sync-store.d.ts +10 -0
  33. package/models/sync-store.js +1 -0
  34. package/models/user.d.ts +7 -0
  35. package/models/user.js +1 -0
  36. package/package.json +2 -2
  37. package/tools/__tests__/parent-folder.spec.d.ts +1 -0
  38. package/tools/__tests__/parent-folder.spec.js +14 -0
  39. package/tools/get-file-name.d.ts +1 -0
  40. package/tools/get-file-name.js +3 -0
  41. package/tools/get-parent-dir.d.ts +1 -0
  42. package/tools/get-parent-dir.js +7 -0
  43. package/tools/index.d.ts +1 -0
  44. package/tools/index.js +1 -0
package/api.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { Command, CSSVariable, ThemeVariable, Note, InlineEmbeddedWidget, MultilineEmbeddedWidget, OrgLineClass, WidgetBuilder, CommandPreview, OrgNoteEncryption, Modal } from './models/index.js';
1
+ import { Command, CSSVariable, ThemeVariable, Note, InlineEmbeddedWidget, MultilineEmbeddedWidget, OrgLineClass, FileSystem, WidgetBuilder, CommandPreview, OrgNoteEncryption, Modal, SyncStoreDefinition, FilesStoreDefinition, FileOpenerStoreDefinition, FileManageStoreDefinition } from './models/index.js';
2
2
  import type { NavigationFailure } from 'vue-router';
3
3
  import { WidgetType } from './models/widget-type.js';
4
4
  import type { Component } from 'vue';
5
5
  import { NodeType } from 'org-mode-ast';
6
6
  import { EditorExtension } from './models/editor.js';
7
+ import { AuthStoreDefinition } from './models/auth-store.js';
7
8
  type WithNodeType<T> = {
8
9
  nodeType: NodeType;
9
10
  } & T;
@@ -60,8 +61,13 @@ export interface OrgNoteApi {
60
61
  }) => WidgetBuilder;
61
62
  };
62
63
  };
63
- fileSystem: {
64
- readPath: () => Promise<string>;
64
+ core: {
65
+ useFileSystem: () => FileSystem;
66
+ useSyncStore: SyncStoreDefinition;
67
+ useFilesStore: FilesStoreDefinition;
68
+ useFileOpenerStore: FileOpenerStoreDefinition;
69
+ useFileManagerStore: FileManageStoreDefinition;
70
+ useAuthStore: AuthStoreDefinition;
65
71
  };
66
72
  commands: {
67
73
  add(...commands: Command[]): void;
@@ -1,4 +1,4 @@
1
- import { encryptViaKeys, decryptViaKeys, encryptViaPassword, decryptViaPassword, NoKeysProvidedError, NoPasswordProvidedError, IncorrectOrMissingPrivateKeyPasswordError, encrypt, decrypt, armor, unarmor, } from "../encryption.js";
1
+ import { encryptViaKeys, decryptViaKeys, encryptViaPassword, decryptViaPassword, NoKeysProvidedError, NoPasswordProvidedError, IncorrectOrMissingPrivateKeyPasswordError, encrypt, decrypt, armor, unarmor, ImpossibleToDecryptWithProvidedKeysError, } from "../encryption.js";
2
2
  import { test, expect } from 'vitest';
3
3
  import { armoredPublicKey, armoredPrivateKey, privateKeyPassphrase, } from "./encryption-keys.js";
4
4
  import { ModelsPublicNoteEncryptionTypeEnum } from "../../remote-api/index.js";
@@ -285,3 +285,58 @@ test('Should decrypt value from provided real world data and passwords', async (
285
285
  });
286
286
  expect(decryptedMessage).toEqual('Hello world!');
287
287
  });
288
+ test.only('Should raise error when incorrect encryption key are provided', async () => {
289
+ const armoredContent = `-----BEGIN PGP MESSAGE-----
290
+
291
+ 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
328
+ =vQdH
329
+ -----END PGP MESSAGE-----
330
+ `;
331
+ try {
332
+ const decryptedMessage = await decrypt({
333
+ content: armoredContent,
334
+ type: 'gpgPassword',
335
+ format: 'utf8',
336
+ password: 'qweqwebebe1',
337
+ });
338
+ }
339
+ catch (e) {
340
+ expect(e).toBeInstanceOf(ImpossibleToDecryptWithProvidedKeysError);
341
+ }
342
+ });
@@ -4,8 +4,8 @@ export function orgnodeToNote(orgnode, fileInfo) {
4
4
  id: orgnode.meta.id,
5
5
  meta: orgnode.meta,
6
6
  filePath: splitPath(fileInfo.path),
7
- touchedAt: new Date(fileInfo.atime).toISOString(),
7
+ touchedAt: fileInfo.atime && new Date(fileInfo.atime).toISOString(),
8
8
  updatedAt: new Date(Math.max(fileInfo.mtime, fileInfo.ctime)).toISOString(),
9
- createdAt: new Date(fileInfo.ctime).toISOString(),
9
+ createdAt: fileInfo.ctime && new Date(fileInfo.ctime).toISOString(),
10
10
  };
11
11
  }
@@ -0,0 +1,21 @@
1
+ import type { Ref } from 'vue';
2
+ import { Store } from './store.js';
3
+ import { PersonalInfo } from './user.js';
4
+ import { OAuthProvider } from './oauth-provider.js';
5
+ export interface AuthStore {
6
+ token: Ref<string>;
7
+ user: Ref<PersonalInfo>;
8
+ provider: Ref<OAuthProvider>;
9
+ auth: (params: {
10
+ provider: string;
11
+ environment?: string;
12
+ redirectUrl?: string;
13
+ }) => Promise<void>;
14
+ authViaGithub: (redirectUrl: string) => Promise<void>;
15
+ logout: () => Promise<void>;
16
+ verifyUser: () => Promise<void>;
17
+ authUser: (u: PersonalInfo, token: string) => Promise<void>;
18
+ subscribe: (token: string, email?: string) => Promise<void>;
19
+ removeUserAccount: () => Promise<void>;
20
+ }
21
+ export type AuthStoreDefinition = Store<AuthStore>;
@@ -0,0 +1 @@
1
+ export {};
@@ -16,10 +16,9 @@ export interface CommandMeta<T = any> extends Partial<CommandPreview> {
16
16
  keySequence?: string | string[];
17
17
  group?: CommandGroup;
18
18
  allowOnInput?: boolean;
19
- ignorePrompt?: boolean;
20
19
  interactive?: boolean;
21
20
  system?: boolean;
22
- available?: () => boolean;
21
+ disabled?: () => boolean;
23
22
  context?: {
24
23
  [key: string]: T;
25
24
  };
@@ -26,5 +26,8 @@ export declare enum DefaultCommands {
26
26
  OPEN_GRAPH = "graph",
27
27
  OPEN_EXTENSIONS = "extensions",
28
28
  SELECT_FILE_PATH = "select file path",
29
- PICK_SYNC_DIR = "pick sync dir"
29
+ PICK_SYNC_DIR = "pick sync dir",
30
+ SYNC_FILES = "sync files",
31
+ ENCRYPT_NOTE = "encrypt note",
32
+ DECRYPT_NOTE = "decrypt note"
30
33
  }
@@ -38,4 +38,8 @@ export var DefaultCommands;
38
38
  // Native mobile specific
39
39
  DefaultCommands["SELECT_FILE_PATH"] = "select file path";
40
40
  DefaultCommands["PICK_SYNC_DIR"] = "pick sync dir";
41
+ // File management
42
+ DefaultCommands["SYNC_FILES"] = "sync files";
43
+ DefaultCommands["ENCRYPT_NOTE"] = "encrypt note";
44
+ DefaultCommands["DECRYPT_NOTE"] = "decrypt note";
41
45
  })(DefaultCommands || (DefaultCommands = {}));
@@ -0,0 +1,12 @@
1
+ export interface FileCache {
2
+ fileName: string;
3
+ filePath: string;
4
+ fileExtension: string;
5
+ updatedAt?: Date;
6
+ createdAt?: Date;
7
+ touchedAt?: Date;
8
+ size: number;
9
+ backlinksPaths?: string[];
10
+ deletedAt?: Date;
11
+ uploaded?: boolean;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Ref } from 'vue';
2
+ import { Store } from './store.js';
3
+ import { FileNode } from './file-tree.js';
4
+ export interface FileManagerStore {
5
+ fileTree: Ref<FileNode[]>;
6
+ renameFile: (fileNode: FileNode, newName: string) => Promise<void>;
7
+ deleteFile: (fileNode: FileNode) => Promise<void>;
8
+ updateFileManager: () => void;
9
+ createFolder: (name?: string) => Promise<void>;
10
+ editedFileItem: Ref<FileNode>;
11
+ stopEdit: () => void;
12
+ expandedNodes: Ref<string[]>;
13
+ }
14
+ export type FileManageStoreDefinition = Store<FileManagerStore>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { Store } from './store.js';
2
+ export interface FileOpenerStore {
3
+ openFile: (path: string[]) => Promise<void>;
4
+ }
5
+ export type FileOpenerStoreDefinition = Store<FileOpenerStore>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface FilePathInfo {
2
+ filePath: string[];
3
+ id: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
File without changes
File without changes
@@ -10,7 +10,7 @@ export interface FileInfo {
10
10
  uri?: string;
11
11
  }
12
12
  export interface FileSystem {
13
- readFile: <T extends 'utf8'>(path: string, encoding?: T) => Promise<T extends 'utf8' ? string : Uint8Array>;
13
+ readFile: <T extends 'utf8' | 'binary' = 'utf8', R = T extends 'utf8' ? string : Uint8Array>(path: string, encoding?: T) => Promise<R>;
14
14
  writeFile: (path: string, content: string | Uint8Array, encoding?: BufferEncoding) => Promise<void>;
15
15
  readDir: (path: string) => Promise<FileInfo[]>;
16
16
  fileInfo: (path: string) => Promise<FileInfo>;
@@ -20,4 +20,5 @@ export interface FileSystem {
20
20
  mkdir: (path: string) => Promise<void>;
21
21
  isDirExist: (path: string) => Promise<boolean>;
22
22
  isFileExist: (path: string) => Promise<boolean>;
23
+ utimeSync: (path: string, atime?: string | number | Date, mtime?: string | number | Date) => Promise<void>;
23
24
  }
@@ -0,0 +1,12 @@
1
+ export interface FileNode {
2
+ name: string;
3
+ id?: string;
4
+ filePath: string[];
5
+ type: 'file' | 'directory';
6
+ meta?: {
7
+ color?: string;
8
+ icon?: string;
9
+ [key: string]: unknown;
10
+ };
11
+ children?: FileNode[];
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Store } from './store.js';
2
+ export interface FilesStore {
3
+ getBlobUrl: (filePath: string) => Promise<string>;
4
+ uploadMediaFile: (path?: string) => Promise<string>;
5
+ }
6
+ export type FilesStoreDefinition = Store<FilesStore>;
@@ -0,0 +1 @@
1
+ export {};
package/models/index.d.ts CHANGED
@@ -11,3 +11,14 @@ export * from './default-commands.js';
11
11
  export * from './encryption.js';
12
12
  export * from './file-system.js';
13
13
  export * from './sync.js';
14
+ export * from './file-cache.js';
15
+ export * from './file-path.js';
16
+ export * from './file-tree.js';
17
+ export * from './user.js';
18
+ export * from './oauth-provider.js';
19
+ export * from './sync-store.js';
20
+ export * from './files-store.js';
21
+ export * from './file-opener-store.js';
22
+ export * from './file-manager-store.js';
23
+ export * from './auth-store.js';
24
+ export * from './repositories.js';
package/models/index.js CHANGED
@@ -11,3 +11,16 @@ export * from "./default-commands.js";
11
11
  export * from "./encryption.js";
12
12
  export * from "./file-system.js";
13
13
  export * from "./sync.js";
14
+ export * from "./file-cache.js";
15
+ export * from "./file-path.js";
16
+ export * from "./file-tree.js";
17
+ export * from "./user.js";
18
+ export * from "./oauth-provider.js";
19
+ // Stores
20
+ export * from "./sync-store.js";
21
+ export * from "./files-store.js";
22
+ export * from "./file-opener-store.js";
23
+ export * from "./file-manager-store.js";
24
+ export * from "./auth-store.js";
25
+ // Repositories
26
+ export * from "./repositories.js";
@@ -0,0 +1 @@
1
+ export type OAuthProvider = 'github' | 'google';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
1
+ import { ExtensionMeta, StoredExtension } from './extension.js';
2
+ import { FileCache } from './file-cache.js';
3
+ import { FilePathInfo } from './file-path.js';
4
+ import { Note, NotePreview } from './note.js';
5
+ export interface ExtensionRepository {
6
+ getMeta(): Promise<ExtensionMeta[]>;
7
+ getActiveExtensions(): Promise<StoredExtension[]>;
8
+ setActiveStatus(extensionName: string, active: boolean): Promise<void>;
9
+ activateExtension(extensionName: string): Promise<void>;
10
+ deactivateExtension(extensionName: string): Promise<void>;
11
+ upsertExtensions(extensions: StoredExtension[]): Promise<void>;
12
+ getExtension(extensionName: string): Promise<StoredExtension>;
13
+ getExtensionBySource(source: string): Promise<StoredExtension>;
14
+ deleteBySource(source: string): Promise<void>;
15
+ delete(extensionName: string): Promise<void>;
16
+ }
17
+ export interface FileRepository {
18
+ upsert(file: FileCache): Promise<void>;
19
+ bulkUpsert(file: FileCache[]): Promise<void>;
20
+ update(filePath: string, file: Partial<FileCache>): Promise<void>;
21
+ delete(filePath: string): Promise<void>;
22
+ markAsDelete(filePath: string, deletedAt?: Date): Promise<void>;
23
+ clear(): Promise<void>;
24
+ getFirstUnuploaded(): Promise<FileCache>;
25
+ search(text: string): Promise<FileCache[]>;
26
+ getByPath(path: string): Promise<FileCache>;
27
+ getAll(): Promise<FileCache[]>;
28
+ getFilesAfterUpdateTime(updatedTime?: Date): Promise<FileCache[]>;
29
+ count(updatedTime?: Date): Promise<number>;
30
+ }
31
+ export interface NoteRepository {
32
+ getNotesAfterUpdateTime(updatedTime?: string): Promise<Note[]>;
33
+ getDeletedNotes(): Promise<Note[]>;
34
+ saveNotes(notes: Note[]): Promise<void>;
35
+ putNote(note: Note): Promise<void>;
36
+ getById(id: string): Promise<Note>;
37
+ getByPath(path: string[]): Promise<Note>;
38
+ getNotePreviews(options?: {
39
+ limit?: number;
40
+ offset?: number;
41
+ searchText?: string;
42
+ tags?: string[];
43
+ bookmarked?: boolean;
44
+ }): Promise<NotePreview[]>;
45
+ deleteNotes(noteIds: string[]): Promise<void>;
46
+ markAsDeleted(noteIds: string[]): Promise<void>;
47
+ bulkPartialUpdate(updates: {
48
+ id: string;
49
+ changes: Partial<Note>;
50
+ }[]): Promise<void>;
51
+ count(searchText?: string, tags?: string[]): Promise<number>;
52
+ getFilePaths(): Promise<FilePathInfo[]>;
53
+ touchNote(noteId: string): Promise<void>;
54
+ getTagsStatistic(): Promise<{
55
+ tag: string;
56
+ count: number;
57
+ }[]>;
58
+ addBookmark(noteId: string): Promise<void>;
59
+ deleteBookmark(noteId: string): Promise<void>;
60
+ modify(modifyCallback: (note: Note, ref: {
61
+ value: Note;
62
+ }) => void): Promise<void>;
63
+ getIds(filterCb?: (n: Note) => boolean): Promise<string[]>;
64
+ clear(): Promise<void>;
65
+ }
66
+ export interface Repositories {
67
+ notes: NoteRepository;
68
+ files: FileRepository;
69
+ extensions: ExtensionRepository;
70
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { defineStore } from 'pinia';
2
+ export type Store<T> = ReturnType<typeof defineStore<string, T>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { Ref } from 'vue';
2
+ import { Store } from './store.js';
3
+ export interface SyncStore {
4
+ markToSync: () => Promise<void>;
5
+ sync: () => Promise<void>;
6
+ forceResync: () => Promise<void>;
7
+ lastSyncTime: Ref<string>;
8
+ reset: () => void;
9
+ }
10
+ export type SyncStoreDefinition = Store<SyncStore>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ModelsPublicUser, ModelsUserPersonalInfo } from "../remote-api/index.js";
2
+ export interface User extends ModelsPublicUser {
3
+ isAnonymous?: boolean;
4
+ }
5
+ export interface PersonalInfo extends ModelsUserPersonalInfo {
6
+ isAnonymous?: boolean;
7
+ }
package/models/user.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -45,7 +45,7 @@
45
45
  "axios": "1.7.3",
46
46
  "openpgp": "5.11.1",
47
47
  "org-mode-ast": "0.11.7",
48
- "orgnote-api": "0.16.0",
48
+ "pinia": "2.1.7",
49
49
  "vue": "3.4.15",
50
50
  "vue-router": "4.2.5"
51
51
  },
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { test, expect } from 'vitest';
2
+ import { getParentDir } from "../get-parent-dir.js";
3
+ test('Should return correct parent dirs', () => {
4
+ expect(getParentDir('some/path/to/file')).toBe('some/path/to');
5
+ expect(getParentDir('another/path/to/dir/')).toBe('another/path/to');
6
+ expect(getParentDir(['root', 'folder', 'subfolder'])).toBe('root/folder');
7
+ expect(getParentDir('single')).toBe('');
8
+ expect(getParentDir('/file')).toBe('');
9
+ expect(getParentDir(['/'])).toBe('');
10
+ expect(getParentDir('file')).toBe('');
11
+ });
12
+ test('Should not return parent dir when file at the root', () => {
13
+ expect(getParentDir('')).toBe('');
14
+ });
@@ -1,2 +1,3 @@
1
1
  export declare const getFileName: (path: string) => string;
2
2
  export declare const getFileNameWithoutExtension: (path: string) => string;
3
+ export declare const getFileExtension: (path: string) => string;
@@ -4,3 +4,6 @@ export const getFileName = (path) => {
4
4
  export const getFileNameWithoutExtension = (path) => {
5
5
  return getFileName(path).split('.').shift();
6
6
  };
7
+ export const getFileExtension = (path) => {
8
+ return getFileName(path).split('.').pop();
9
+ };
@@ -0,0 +1 @@
1
+ export declare function getParentDir(path: string | string[]): string;
@@ -0,0 +1,7 @@
1
+ import { splitPath } from "./split-path.js";
2
+ export function getParentDir(path) {
3
+ if (typeof path === 'string') {
4
+ path = splitPath(path);
5
+ }
6
+ return path.slice(0, -1).join('/');
7
+ }
package/tools/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export * from './get-file-name.js';
6
6
  export * from './find-notes-files-diff.js';
7
7
  export * from './join-path.js';
8
8
  export * from './split-path.js';
9
+ export * from './get-parent-dir.js';
package/tools/index.js CHANGED
@@ -6,3 +6,4 @@ export * from "./get-file-name.js";
6
6
  export * from "./find-notes-files-diff.js";
7
7
  export * from "./join-path.js";
8
8
  export * from "./split-path.js";
9
+ export * from "./get-parent-dir.js";