orgnote-api 0.18.0 → 0.18.2
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 +11 -5
- package/encryption/__tests__/encryption.spec.js +3 -3
- package/encryption/__tests__/note-encryption.spec.js +3 -3
- package/encryption/encryption.d.ts +2 -2
- package/encryption/encryption.js +1 -1
- package/encryption/index.d.ts +2 -2
- package/encryption/index.js +2 -2
- package/encryption/note-encryption.d.ts +1 -1
- package/encryption/note-encryption.js +3 -3
- package/index.d.ts +6 -6
- package/index.js +6 -6
- package/mappers/index.d.ts +1 -1
- package/mappers/index.js +1 -1
- package/mappers/orgnode-to-note.d.ts +1 -1
- package/mappers/orgnode-to-note.js +3 -3
- package/models/auth-store.d.ts +21 -0
- package/models/auth-store.js +1 -0
- package/models/command.d.ts +1 -1
- package/models/default-commands.d.ts +2 -1
- package/models/default-commands.js +2 -0
- package/models/editor.d.ts +1 -1
- package/models/encryption.d.ts +1 -1
- package/models/extension.d.ts +1 -1
- package/models/file-cache.d.ts +12 -0
- package/models/file-cache.js +1 -0
- package/models/file-manager-store.d.ts +14 -0
- package/models/file-manager-store.js +1 -0
- package/models/file-opener-store.d.ts +5 -0
- package/models/file-opener-store.js +1 -0
- package/models/file-path.d.ts +4 -0
- package/models/file-path.js +1 -0
- package/models/file-system-store.d.ts +0 -0
- package/models/file-system-store.js +0 -0
- package/models/file-system.d.ts +2 -1
- package/models/file-tree.d.ts +12 -0
- package/models/file-tree.js +1 -0
- package/models/files-store.d.ts +6 -0
- package/models/files-store.js +1 -0
- package/models/index.d.ts +24 -13
- package/models/index.js +26 -13
- package/models/modal.d.ts +1 -1
- package/models/note.d.ts +1 -1
- package/models/oauth-provider.d.ts +1 -0
- package/models/oauth-provider.js +1 -0
- package/models/repositories.d.ts +70 -0
- package/models/repositories.js +1 -0
- package/models/store.d.ts +2 -0
- package/models/store.js +1 -0
- package/models/sync-store.d.ts +10 -0
- package/models/sync-store.js +1 -0
- package/models/sync.d.ts +2 -2
- package/models/user.d.ts +7 -0
- package/models/user.js +1 -0
- package/package.json +14 -3
- package/remote-api/api.d.ts +3 -3
- package/remote-api/api.js +2 -2
- package/remote-api/base.d.ts +1 -1
- package/remote-api/common.d.ts +2 -2
- package/remote-api/common.js +1 -1
- package/remote-api/index.d.ts +2 -2
- package/remote-api/index.js +2 -2
- package/tools/__tests__/find-files-diff.spec.js +1 -1
- package/tools/__tests__/find-note-files-diff.spec.js +3 -3
- package/tools/__tests__/get-file-name.spec.js +1 -1
- package/tools/__tests__/get-string-path.spec.js +1 -1
- package/tools/__tests__/is-gpg-encrypted.spec.js +1 -1
- package/tools/__tests__/is-org-file.spec.js +1 -1
- package/tools/__tests__/join.spec.js +1 -1
- package/tools/__tests__/parent-folder.spec.d.ts +1 -0
- package/tools/__tests__/parent-folder.spec.js +14 -0
- package/tools/__tests__/read-org-files-recursively.spec.js +1 -1
- package/tools/__tests__/split-path.spec.js +1 -1
- package/tools/extend-notes-files-diff.d.ts +2 -2
- package/tools/extend-notes-files-diff.js +1 -1
- package/tools/find-notes-files-diff.d.ts +1 -1
- package/tools/find-notes-files-diff.js +3 -3
- package/tools/get-file-name.d.ts +1 -0
- package/tools/get-file-name.js +3 -0
- package/tools/get-parent-dir.d.ts +1 -0
- package/tools/get-parent-dir.js +7 -0
- package/tools/index.d.ts +9 -8
- package/tools/index.js +9 -8
package/api.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Command, CSSVariable, ThemeVariable, Note, InlineEmbeddedWidget, MultilineEmbeddedWidget, OrgLineClass, WidgetBuilder, CommandPreview, OrgNoteEncryption, Modal } from './models';
|
|
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
|
-
import { WidgetType } from './models/widget-type';
|
|
3
|
+
import { WidgetType } from './models/widget-type.js';
|
|
4
4
|
import type { Component } from 'vue';
|
|
5
5
|
import { NodeType } from 'org-mode-ast';
|
|
6
|
-
import { EditorExtension } from './models/editor';
|
|
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
|
-
|
|
64
|
-
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import { encryptViaKeys, decryptViaKeys, encryptViaPassword, decryptViaPassword, NoKeysProvidedError, NoPasswordProvidedError, IncorrectOrMissingPrivateKeyPasswordError, encrypt, decrypt, armor, unarmor, } from
|
|
1
|
+
import { encryptViaKeys, decryptViaKeys, encryptViaPassword, decryptViaPassword, NoKeysProvidedError, NoPasswordProvidedError, IncorrectOrMissingPrivateKeyPasswordError, encrypt, decrypt, armor, unarmor, } from "../encryption.js";
|
|
2
2
|
import { test, expect } from 'vitest';
|
|
3
|
-
import { armoredPublicKey, armoredPrivateKey, privateKeyPassphrase, } from
|
|
4
|
-
import { ModelsPublicNoteEncryptionTypeEnum } from
|
|
3
|
+
import { armoredPublicKey, armoredPrivateKey, privateKeyPassphrase, } from "./encryption-keys.js";
|
|
4
|
+
import { ModelsPublicNoteEncryptionTypeEnum } from "../../remote-api/index.js";
|
|
5
5
|
test('Should encrypt text as armored message via keys', async () => {
|
|
6
6
|
const res = await encryptViaKeys({
|
|
7
7
|
type: ModelsPublicNoteEncryptionTypeEnum.GpgKeys,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect, test } from 'vitest';
|
|
2
|
-
import { decryptNote, encryptNote } from
|
|
3
|
-
import { armoredPublicKey, armoredPrivateKey, privateKeyPassphrase, } from
|
|
4
|
-
import { ModelsPublicNoteEncryptionTypeEnum } from
|
|
2
|
+
import { decryptNote, encryptNote } from "../note-encryption.js";
|
|
3
|
+
import { armoredPublicKey, armoredPrivateKey, privateKeyPassphrase, } from "./encryption-keys.js";
|
|
4
|
+
import { ModelsPublicNoteEncryptionTypeEnum } from "../../remote-api/index.js";
|
|
5
5
|
test('Should encrypt note content via password', async () => {
|
|
6
6
|
const noteText = `#+ID: qweqwe
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Stream } from 'openpgp';
|
|
2
|
-
import { OrgNoteEncryption, OrgNotePasswordEncryption, WithDecryptionContent } from '../models/encryption';
|
|
3
|
-
import { OrgNoteGpgEncryption, WithEncryptionContent } from '../models';
|
|
2
|
+
import { OrgNoteEncryption, OrgNotePasswordEncryption, WithDecryptionContent } from '../models/encryption.js';
|
|
3
|
+
import { OrgNoteGpgEncryption, WithEncryptionContent } from '../models/index.js';
|
|
4
4
|
import { enums } from 'openpgp';
|
|
5
5
|
export declare class IncorrectOrMissingPrivateKeyPasswordError extends Error {
|
|
6
6
|
}
|
package/encryption/encryption.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createMessage, decrypt as _decrypt, decryptKey, encrypt as _encrypt, readKey, readMessage, readPrivateKey, } from 'openpgp';
|
|
2
|
-
import { ModelsPublicNoteEncryptionTypeEnum } from
|
|
2
|
+
import { ModelsPublicNoteEncryptionTypeEnum } from "../remote-api/index.js";
|
|
3
3
|
import { armor as _armor, unarmor as _unarmor, enums } from 'openpgp';
|
|
4
4
|
export class IncorrectOrMissingPrivateKeyPasswordError extends Error {
|
|
5
5
|
}
|
package/encryption/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './note-encryption';
|
|
2
|
-
export * from './encryption';
|
|
1
|
+
export * from './note-encryption.js';
|
|
2
|
+
export * from './encryption.js';
|
package/encryption/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./note-encryption.js";
|
|
2
|
+
export * from "./encryption.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OrgNoteEncryption, WithEncryptionContent, WithNoteDecryptionContent } from '../models/encryption';
|
|
1
|
+
import { OrgNoteEncryption, WithEncryptionContent, WithNoteDecryptionContent } from '../models/encryption.js';
|
|
2
2
|
export interface AbstractEncryptedNote {
|
|
3
3
|
encrypted?: boolean;
|
|
4
4
|
meta: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModelsPublicNoteEncryptionTypeEnum } from
|
|
2
|
-
import { decrypt, encrypt } from
|
|
1
|
+
import { ModelsPublicNoteEncryptionTypeEnum } from "../remote-api/index.js";
|
|
2
|
+
import { decrypt, encrypt } from "./encryption.js";
|
|
3
3
|
import { parse, withMetaInfo } from 'org-mode-ast';
|
|
4
|
-
import { isGpgEncrypted } from '
|
|
4
|
+
import { isGpgEncrypted } from '../index.js';
|
|
5
5
|
// TODO: master change signature for encrypt notes without content
|
|
6
6
|
export async function encryptNote(note, encryptionParams) {
|
|
7
7
|
note.encrypted = false;
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './api';
|
|
2
|
-
export * from './models';
|
|
1
|
+
export * from './api.js';
|
|
2
|
+
export * from './models/index.js';
|
|
3
3
|
import type * as ast from 'org-mode-ast';
|
|
4
|
-
export * from './encryption';
|
|
5
|
-
export * from './tools';
|
|
6
|
-
export * from './files-api';
|
|
7
|
-
export * from './mappers';
|
|
4
|
+
export * from './encryption/index.js';
|
|
5
|
+
export * from './tools/index.js';
|
|
6
|
+
export * from './files-api.js';
|
|
7
|
+
export * from './mappers/index.js';
|
|
8
8
|
export { ast };
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./models/index.js";
|
|
3
|
+
export * from "./encryption/index.js";
|
|
4
|
+
export * from "./tools/index.js";
|
|
5
|
+
export * from "./files-api.js";
|
|
6
|
+
export * from "./mappers/index.js";
|
package/mappers/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './orgnode-to-note';
|
|
1
|
+
export * from './orgnode-to-note.js';
|
package/mappers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./orgnode-to-note.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { splitPath } from
|
|
1
|
+
import { splitPath } from "../tools/index.js";
|
|
2
2
|
export function orgnodeToNote(orgnode, fileInfo) {
|
|
3
3
|
return {
|
|
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 {};
|
package/models/command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DefaultCommands } from './default-commands';
|
|
1
|
+
import { DefaultCommands } from './default-commands.js';
|
|
2
2
|
export declare const DEFAULT_KEYBINDING_GROUP = "default";
|
|
3
3
|
export type CommandGroup = 'settings' | 'editor' | 'global' | 'note-detail' | 'completion' | string;
|
|
4
4
|
export interface CommandHandlerParams<T = any> {
|
|
@@ -38,4 +38,6 @@ 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 sync
|
|
42
|
+
DefaultCommands["SYNC_FILES"] = "sync files";
|
|
41
43
|
})(DefaultCommands || (DefaultCommands = {}));
|
package/models/editor.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { OrgNode } from 'org-mode-ast';
|
|
|
2
2
|
import type { Component } from 'vue';
|
|
3
3
|
import type { EditorView } from '@codemirror/view';
|
|
4
4
|
import type { Extension } from '@codemirror/state';
|
|
5
|
-
import { InlineEmbeddedWidget } from './widget';
|
|
5
|
+
import { InlineEmbeddedWidget } from './widget.js';
|
|
6
6
|
interface DynamicComponent {
|
|
7
7
|
mount: (cmp: Component, wrap: Element, props?: {
|
|
8
8
|
[key: string]: unknown;
|
package/models/encryption.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModelsPublicNoteEncryptionTypeEnum } from '../remote-api';
|
|
1
|
+
import type { ModelsPublicNoteEncryptionTypeEnum } from '../remote-api/index.js';
|
|
2
2
|
export type EcnryptionFormat = 'binary' | 'armored';
|
|
3
3
|
export interface BaseOrgNoteEncryption {
|
|
4
4
|
format?: 'binary' | 'armored';
|
package/models/extension.d.ts
CHANGED
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
File without changes
|
package/models/file-system.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface FileInfo {
|
|
|
10
10
|
uri?: string;
|
|
11
11
|
}
|
|
12
12
|
export interface FileSystem {
|
|
13
|
-
readFile: <T extends 'utf8'
|
|
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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/models/index.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
export * from './note';
|
|
2
|
-
export * from './command';
|
|
3
|
-
export * from './completion';
|
|
4
|
-
export * from './extension';
|
|
5
|
-
export * from './theme-variables';
|
|
6
|
-
export * from './widget';
|
|
7
|
-
export * from './modal';
|
|
8
|
-
export * from './widget-type';
|
|
9
|
-
export * from './editor';
|
|
10
|
-
export * from './default-commands';
|
|
11
|
-
export * from './encryption';
|
|
12
|
-
export * from './file-system';
|
|
13
|
-
export * from './sync';
|
|
1
|
+
export * from './note.js';
|
|
2
|
+
export * from './command.js';
|
|
3
|
+
export * from './completion.js';
|
|
4
|
+
export * from './extension.js';
|
|
5
|
+
export * from './theme-variables.js';
|
|
6
|
+
export * from './widget.js';
|
|
7
|
+
export * from './modal.js';
|
|
8
|
+
export * from './widget-type.js';
|
|
9
|
+
export * from './editor.js';
|
|
10
|
+
export * from './default-commands.js';
|
|
11
|
+
export * from './encryption.js';
|
|
12
|
+
export * from './file-system.js';
|
|
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
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
1
|
+
export * from "./note.js";
|
|
2
|
+
export * from "./command.js";
|
|
3
|
+
export * from "./completion.js";
|
|
4
|
+
export * from "./extension.js";
|
|
5
|
+
export * from "./theme-variables.js";
|
|
6
|
+
export * from "./widget.js";
|
|
7
|
+
export * from "./modal.js";
|
|
8
|
+
export * from "./widget-type.js";
|
|
9
|
+
export * from "./editor.js";
|
|
10
|
+
export * from "./default-commands.js";
|
|
11
|
+
export * from "./encryption.js";
|
|
12
|
+
export * from "./file-system.js";
|
|
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";
|
package/models/modal.d.ts
CHANGED
package/models/note.d.ts
CHANGED
|
@@ -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 {};
|
package/models/store.js
ADDED
|
@@ -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 {};
|
package/models/sync.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HandlersCreatingNote } from "../remote-api";
|
|
2
|
-
import { FileSystem } from './file-system';
|
|
1
|
+
import { HandlersCreatingNote } from "../remote-api/index.js";
|
|
2
|
+
import { FileSystem } from './file-system.js';
|
|
3
3
|
export interface Changes {
|
|
4
4
|
deleted: string[];
|
|
5
5
|
created: string[];
|
package/models/user.d.ts
ADDED
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.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Official API for creating extensions for OrgNote app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"codegen:api": "openapi-generator-cli generate",
|
|
13
13
|
"codegen:css-doc": "node collect-css-variables.cjs --docs",
|
|
14
14
|
"codegen:css-types": "node collect-css-variables.cjs --types",
|
|
15
|
-
"
|
|
15
|
+
"fix-esm-imports": "fix-esm-import-path ./dist",
|
|
16
|
+
"prepub": "npm run build && npm run fix-esm-imports && cp -rf package.json package-lock.json README.md dist/",
|
|
16
17
|
"pub": "npm run prepub && cd dist && npm publish",
|
|
17
18
|
"pub:yalc": "npm run prepub && cd dist && yalc publish --push"
|
|
18
19
|
},
|
|
@@ -20,6 +21,14 @@
|
|
|
20
21
|
"type": "git",
|
|
21
22
|
"url": "git+https://github.com/artawower/orgnote-api.git"
|
|
22
23
|
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./index.js",
|
|
26
|
+
"./remote-api": "./remote-api/index.js",
|
|
27
|
+
"./encryption": "./encryption/index.js",
|
|
28
|
+
"./tools": "./tools/index.js",
|
|
29
|
+
"./mappers": "./mappers/index.js",
|
|
30
|
+
"./commands": "./commands/index.js"
|
|
31
|
+
},
|
|
23
32
|
"files": ["**"],
|
|
24
33
|
"types": "./index.d.ts",
|
|
25
34
|
"keywords": ["orgnote", "org-mode", "org-roam", "api", "extensions"],
|
|
@@ -36,16 +45,18 @@
|
|
|
36
45
|
"axios": "1.7.3",
|
|
37
46
|
"openpgp": "5.11.1",
|
|
38
47
|
"org-mode-ast": "0.11.7",
|
|
39
|
-
"
|
|
48
|
+
"pinia": "2.1.7",
|
|
40
49
|
"vue": "3.4.15",
|
|
41
50
|
"vue-router": "4.2.5"
|
|
42
51
|
},
|
|
43
52
|
"devDependencies": {
|
|
44
53
|
"@openapitools/openapi-generator-cli": "2.13.4",
|
|
45
54
|
"@types/node": "20.13.0",
|
|
55
|
+
"fix-esm-import-path": "1.10.0",
|
|
46
56
|
"ts-patch": "3.2.1",
|
|
47
57
|
"typescript": "^5.3.3",
|
|
48
58
|
"typescript-transform-paths": "3.5.1",
|
|
59
|
+
"typescript-transformer-esm": "1.1.0",
|
|
49
60
|
"vitest": "^1.5.0"
|
|
50
61
|
}
|
|
51
62
|
}
|
package/remote-api/api.d.ts
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* https://openapi-generator.tech
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
|
-
import type { Configuration } from './configuration';
|
|
12
|
+
import type { Configuration } from './configuration.js';
|
|
13
13
|
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
14
|
-
import type { RequestArgs } from './base';
|
|
15
|
-
import { BaseAPI } from './base';
|
|
14
|
+
import type { RequestArgs } from './base.js';
|
|
15
|
+
import { BaseAPI } from './base.js';
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
18
|
* @export
|
package/remote-api/api.js
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
import globalAxios from 'axios';
|
|
15
15
|
// Some imports not used depending on template conditions
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
import { DUMMY_BASE_URL, assertParamExists, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from
|
|
17
|
+
import { DUMMY_BASE_URL, assertParamExists, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from "./common.js";
|
|
18
18
|
// @ts-ignore
|
|
19
|
-
import { BASE_PATH, BaseAPI, operationServerMap } from
|
|
19
|
+
import { BASE_PATH, BaseAPI, operationServerMap } from "./base.js";
|
|
20
20
|
export const HandlersCreatingNoteEncryptionTypeEnum = {
|
|
21
21
|
GpgKeys: 'gpgKeys',
|
|
22
22
|
GpgPassword: 'gpgPassword',
|
package/remote-api/base.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* https://openapi-generator.tech
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
|
-
import type { Configuration } from './configuration';
|
|
12
|
+
import type { Configuration } from './configuration.js';
|
|
13
13
|
import type { AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
14
14
|
export declare const BASE_PATH: string;
|
|
15
15
|
/**
|
package/remote-api/common.d.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* https://openapi-generator.tech
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
|
-
import type { Configuration } from "./configuration";
|
|
13
|
-
import type { RequestArgs } from "./base";
|
|
12
|
+
import type { Configuration } from "./configuration.js";
|
|
13
|
+
import type { RequestArgs } from "./base.js";
|
|
14
14
|
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
15
15
|
/**
|
|
16
16
|
*
|
package/remote-api/common.js
CHANGED
package/remote-api/index.d.ts
CHANGED
package/remote-api/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterEach, beforeEach, expect, test } from 'vitest';
|
|
2
2
|
import { mkdirSync, rmdirSync, statSync, utimesSync, writeFileSync } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
import { findFilesDiff } from
|
|
4
|
+
import { findFilesDiff } from "../find-notes-files-diff.js";
|
|
5
5
|
const testFilesFolder = 'src/tools/__tests__/miscellaneous2/';
|
|
6
6
|
function initFiles() {
|
|
7
7
|
mkdirSync(testFilesFolder);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync, utimesSync, readdirSync } from 'fs';
|
|
2
2
|
import { afterEach, beforeEach, test, expect } from 'vitest';
|
|
3
|
-
import { findNoteFilesDiff } from
|
|
3
|
+
import { findNoteFilesDiff } from "../find-notes-files-diff.js";
|
|
4
4
|
import { statSync } from 'fs';
|
|
5
5
|
import { rmSync } from 'fs';
|
|
6
|
-
import { getFileName } from
|
|
7
|
-
import { join } from
|
|
6
|
+
import { getFileName } from "../get-file-name.js";
|
|
7
|
+
import { join } from "../join-path.js";
|
|
8
8
|
const testFilesFolder = 'src/tools/__tests__/miscellaneous/';
|
|
9
9
|
const nestedFolder = 'nested-folder/';
|
|
10
10
|
const fn = (fileName) => `${testFilesFolder}${fileName}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFileName, getFileNameWithoutExtension } from
|
|
1
|
+
import { getFileName, getFileNameWithoutExtension } from "../get-file-name.js";
|
|
2
2
|
import { test, expect } from 'vitest';
|
|
3
3
|
test('Should return file name from path', () => {
|
|
4
4
|
expect(getFileName('/some/path/foo.org')).toBe('foo.org');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect, test } from 'vitest';
|
|
2
|
-
import { isGpgEncrypted } from
|
|
2
|
+
import { isGpgEncrypted } from "../is-gpg-encrypted.js";
|
|
3
3
|
test('Should return true if the content is gpg encrypted', () => {
|
|
4
4
|
const content = `-----BEGIN PGP MESSAGE-----
|
|
5
5
|
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { readOrgFilesRecursively } from
|
|
2
|
+
import { readOrgFilesRecursively } from "../find-notes-files-diff.js";
|
|
3
3
|
// NOTE: AI generated
|
|
4
4
|
const mockReadDir = vi.fn();
|
|
5
5
|
const mockFileInfo = vi.fn();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
|
-
import { splitPath } from
|
|
2
|
+
import { splitPath } from "../index.js";
|
|
3
3
|
test('Should correctly split various paths with different formats', () => {
|
|
4
4
|
const pathExpected = [
|
|
5
5
|
['/some/long/path/file.txt', ['some', 'long', 'path', 'file.txt']],
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { HandlersSyncNotesRequest } from "../remote-api";
|
|
2
|
-
import { NoteChanges, FileSystem } from '../models';
|
|
1
|
+
import { HandlersSyncNotesRequest } from "../remote-api/index.js";
|
|
2
|
+
import { NoteChanges, FileSystem } from '../models/index.js';
|
|
3
3
|
export declare function extendNotesFilesDiff(changes: NoteChanges, readFile: FileSystem['readFile']): Promise<HandlersSyncNotesRequest>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SyncParams, Changes, StoredNoteInfo, NoteChanges, FileScanParams, FileSystem } from "../models";
|
|
1
|
+
import { SyncParams, Changes, StoredNoteInfo, NoteChanges, FileScanParams, FileSystem } from "../models/index.js";
|
|
2
2
|
export declare function findNoteFilesDiff({ fileInfo, readDir, lastSync, storedNotesInfo, dirPath, }: SyncParams): Promise<NoteChanges>;
|
|
3
3
|
export declare function getOrgFilesFromLastSync(filePaths: string[], fileInfo: FileSystem['fileInfo'], lastSync?: Date): Promise<string[]>;
|
|
4
4
|
export declare function readOrgFilesRecursively({ fileInfo, readDir, dirPath, }: FileScanParams): Promise<string[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getStringPath } from
|
|
2
|
-
import { isOrgFile } from
|
|
3
|
-
import { join } from
|
|
1
|
+
import { getStringPath } from "./get-string-path.js";
|
|
2
|
+
import { isOrgFile } from "./is-org-file.js";
|
|
3
|
+
import { join } from "./join-path.js";
|
|
4
4
|
export async function findNoteFilesDiff({ fileInfo, readDir, lastSync, storedNotesInfo, dirPath, }) {
|
|
5
5
|
const orgFilePaths = await readOrgFilesRecursively({
|
|
6
6
|
fileInfo,
|
package/tools/get-file-name.d.ts
CHANGED
package/tools/get-file-name.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getParentDir(path: string | string[]): string;
|
package/tools/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from './mock-server';
|
|
2
|
-
export * from './is-gpg-encrypted';
|
|
3
|
-
export * from './is-org-file';
|
|
4
|
-
export * from './get-string-path';
|
|
5
|
-
export * from './get-file-name';
|
|
6
|
-
export * from './find-notes-files-diff';
|
|
7
|
-
export * from './join-path';
|
|
8
|
-
export * from './split-path';
|
|
1
|
+
export * from './mock-server.js';
|
|
2
|
+
export * from './is-gpg-encrypted.js';
|
|
3
|
+
export * from './is-org-file.js';
|
|
4
|
+
export * from './get-string-path.js';
|
|
5
|
+
export * from './get-file-name.js';
|
|
6
|
+
export * from './find-notes-files-diff.js';
|
|
7
|
+
export * from './join-path.js';
|
|
8
|
+
export * from './split-path.js';
|
|
9
|
+
export * from './get-parent-dir.js';
|
package/tools/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
1
|
+
export * from "./mock-server.js";
|
|
2
|
+
export * from "./is-gpg-encrypted.js";
|
|
3
|
+
export * from "./is-org-file.js";
|
|
4
|
+
export * from "./get-string-path.js";
|
|
5
|
+
export * from "./get-file-name.js";
|
|
6
|
+
export * from "./find-notes-files-diff.js";
|
|
7
|
+
export * from "./join-path.js";
|
|
8
|
+
export * from "./split-path.js";
|
|
9
|
+
export * from "./get-parent-dir.js";
|