orgnote-api 0.19.4 → 0.19.7
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/README.md +44 -24
- package/constants/command-groups.contant.d.ts +7 -0
- package/constants/command-groups.contant.js +13 -0
- package/encryption/__tests__/encryption.spec.js +1 -1
- package/encryption/__tests__/note-encryption.spec.js +1 -0
- package/encryption/encryption.js +4 -0
- package/models/command.d.ts +5 -4
- package/models/command.js +1 -1
- package/models/file-system.d.ts +1 -0
- package/models/modal.d.ts +1 -1
- package/models/vue-component.d.ts +1 -1
- package/package.json +8 -3
- package/tools/__tests__/find-files-diff.spec.js +3 -1
- package/tools/__tests__/find-note-files-diff.spec.js +3 -1
- package/tools/extend-notes-files-diff.d.ts +0 -3
- package/tools/extend-notes-files-diff.js +0 -21
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
# Table of Contents
|
|
3
3
|
|
|
4
|
-
1. [Introduction](#
|
|
5
|
-
2. [Connected links](#
|
|
6
|
-
3. [Extension structure](#
|
|
7
|
-
1. [Folder structure](#
|
|
8
|
-
2. [Extension entrypoint](#
|
|
9
|
-
3. [Extension manifest](#
|
|
10
|
-
4. [Extension API](#
|
|
11
|
-
4. [Publish to official repository](#
|
|
12
|
-
5. [Extensions example](#
|
|
13
|
-
6. [Contribute guide](#
|
|
4
|
+
1. [Introduction](#orgc594aa4)
|
|
5
|
+
2. [Connected links](#orgc85c296)
|
|
6
|
+
3. [Extension structure](#org995dbfb)
|
|
7
|
+
1. [Folder structure](#orgbf00b5e)
|
|
8
|
+
2. [Extension entrypoint](#org6167fba)
|
|
9
|
+
3. [Extension manifest](#org76005de)
|
|
10
|
+
4. [Extension API](#org222bab3)
|
|
11
|
+
4. [Publish to official repository](#org1e5d376)
|
|
12
|
+
5. [Extensions example](#org3022e0a)
|
|
13
|
+
6. [🍩 Contribute guide](#org576c632)
|
|
14
14
|
|
|
15
15
|
<div align='center'>
|
|
16
16
|
|
|
@@ -34,14 +34,34 @@
|
|
|
34
34
|
|
|
35
35
|
</span>
|
|
36
36
|
|
|
37
|
-
<a href=
|
|
37
|
+
<a href="https://wakatime.com/badge/github/Artawower/orgnote-api"><img src="https://wakatime.com/badge/github/Artawower/orgnote-api.svg" alt="wakatime"></a>
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div align='center'>
|
|
42
|
+
|
|
43
|
+
<a href="https://twitter.com/org_note" target="_blank"><img src="https://img.shields.io/twitter/follow/org_note" alt="Twitter link" /></a>
|
|
44
|
+
|
|
45
|
+
<a href="https://emacs.ch/@orgnote" target="_blank"><img alt="Mastodon Follow" src="https://img.shields.io/mastodon/follow/113090697216193319?domain=https%3A%2F%2Ffosstodon.org&style=social"></a>
|
|
46
|
+
|
|
47
|
+
<a href="https://discord.com/invite/SFpUb2vSDm" target="_blank"><img src="https://img.shields.io/discord/1161751315324604417" alt="Discord"></a>
|
|
48
|
+
|
|
49
|
+
<a href="https://www.youtube.com/@OrgNote" target="_blank"><img alt="YouTube Channel Views" src="https://img.shields.io/youtube/channel/views/UCN14DUE5umdrlEm7odW3gOw"></a>
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<div align='center'>
|
|
54
|
+
|
|
55
|
+
<a href="https://play.google.com/store/apps/details?id=org.note.app" target="_blank">
|
|
56
|
+
|
|
57
|
+
<img src="./images/google-play.svg" width="140px" height="auto">
|
|
58
|
+
|
|
59
|
+
</a>
|
|
40
60
|
|
|
41
61
|
</div>
|
|
42
62
|
|
|
43
63
|
|
|
44
|
-
<a id="
|
|
64
|
+
<a id="orgc594aa4"></a>
|
|
45
65
|
|
|
46
66
|
# Introduction
|
|
47
67
|
|
|
@@ -52,7 +72,7 @@ This is API for [OrgNote](https://github.com/artawower/orgnote) extensions.
|
|
|
52
72
|
You can find all available methods here. They are currently undocumented.
|
|
53
73
|
|
|
54
74
|
|
|
55
|
-
<a id="
|
|
75
|
+
<a id="orgc85c296"></a>
|
|
56
76
|
|
|
57
77
|
# Connected links
|
|
58
78
|
|
|
@@ -65,19 +85,19 @@ You can find all available methods here. They are currently undocumented.
|
|
|
65
85
|
- [Typescript abstract syntax tree for org mode.](https://github.com/Artawower/org-mode-ast)
|
|
66
86
|
|
|
67
87
|
|
|
68
|
-
<a id="
|
|
88
|
+
<a id="org995dbfb"></a>
|
|
69
89
|
|
|
70
90
|
# Extension structure
|
|
71
91
|
|
|
72
92
|
|
|
73
|
-
<a id="
|
|
93
|
+
<a id="orgbf00b5e"></a>
|
|
74
94
|
|
|
75
95
|
## Folder structure
|
|
76
96
|
|
|
77
97
|
**Compiled extension should be placed in the `index.js` file or `/dist/index.js` file in the public GIT repository**
|
|
78
98
|
|
|
79
99
|
|
|
80
|
-
<a id="
|
|
100
|
+
<a id="org6167fba"></a>
|
|
81
101
|
|
|
82
102
|
## Extension entrypoint
|
|
83
103
|
|
|
@@ -93,7 +113,7 @@ Each extension should **export an object by default** with the following structu
|
|
|
93
113
|
You can find available methods of `OrgNoteApi` [here](https://github.com/Artawower/orgnote-api/blob/master/src/api.ts#L24)
|
|
94
114
|
|
|
95
115
|
|
|
96
|
-
<a id="
|
|
116
|
+
<a id="org76005de"></a>
|
|
97
117
|
|
|
98
118
|
## Extension manifest
|
|
99
119
|
|
|
@@ -123,12 +143,12 @@ Also, each extension should export manifest const:
|
|
|
123
143
|
}
|
|
124
144
|
|
|
125
145
|
|
|
126
|
-
<a id="
|
|
146
|
+
<a id="org222bab3"></a>
|
|
127
147
|
|
|
128
148
|
## Extension API
|
|
129
149
|
|
|
130
150
|
|
|
131
|
-
<a id="
|
|
151
|
+
<a id="org1e5d376"></a>
|
|
132
152
|
|
|
133
153
|
# Publish to official repository
|
|
134
154
|
|
|
@@ -136,7 +156,7 @@ OrgNote has an official [repository](https://github.com/Artawower/orgnote-extens
|
|
|
136
156
|
with `ExtensionManifest`
|
|
137
157
|
|
|
138
158
|
|
|
139
|
-
<a id="
|
|
159
|
+
<a id="org3022e0a"></a>
|
|
140
160
|
|
|
141
161
|
# Extensions example
|
|
142
162
|
|
|
@@ -149,10 +169,10 @@ with `ExtensionManifest`
|
|
|
149
169
|
- [Colorful Headlines (typescript + API package)](https://github.com/Artawower/orgnote-colorful-headlines)
|
|
150
170
|
|
|
151
171
|
|
|
152
|
-
<a id="
|
|
172
|
+
<a id="org576c632"></a>
|
|
153
173
|
|
|
154
|
-
# Contribute guide
|
|
174
|
+
# 🍩 Contribute guide
|
|
155
175
|
|
|
156
|
-
Any contribution is very much appreciated! Please read the [style guide](
|
|
176
|
+
Any contribution is very much appreciated! Please read the [style guide](https://github.com/Artawower/orgnote/wiki/Contribution-guide) before contributing to avoid misunderstandings!
|
|
157
177
|
I would also appreciate it if you would consider becoming my [patron](https://www.patreon.com/artawower)
|
|
158
178
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const SETTINGS_COMMAND_GROUP = "settings";
|
|
2
|
+
export declare const EDITOR_COMMAND_GROUP = "editor";
|
|
3
|
+
export declare const GLOBAL_COMMAND_GROUP = "global";
|
|
4
|
+
export declare const NOTE_DETAIL_COMMAND_GROUP = "note-detail";
|
|
5
|
+
export declare const COMPLETION_COMMAND_GROUP = "completion";
|
|
6
|
+
export declare const COMMAND_GROUPS: readonly ["settings", "editor", "global", "note-detail", "completion"];
|
|
7
|
+
export declare const DEFAULT_KEYBINDING_GROUP = "default";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const SETTINGS_COMMAND_GROUP = 'settings';
|
|
2
|
+
export const EDITOR_COMMAND_GROUP = 'editor';
|
|
3
|
+
export const GLOBAL_COMMAND_GROUP = 'global';
|
|
4
|
+
export const NOTE_DETAIL_COMMAND_GROUP = 'note-detail';
|
|
5
|
+
export const COMPLETION_COMMAND_GROUP = 'completion';
|
|
6
|
+
export const COMMAND_GROUPS = [
|
|
7
|
+
SETTINGS_COMMAND_GROUP,
|
|
8
|
+
EDITOR_COMMAND_GROUP,
|
|
9
|
+
GLOBAL_COMMAND_GROUP,
|
|
10
|
+
NOTE_DETAIL_COMMAND_GROUP,
|
|
11
|
+
COMPLETION_COMMAND_GROUP,
|
|
12
|
+
];
|
|
13
|
+
export const DEFAULT_KEYBINDING_GROUP = 'default';
|
|
@@ -355,6 +355,7 @@ test('Should encrypt note to binary format', async () => {
|
|
|
355
355
|
});
|
|
356
356
|
expect(encryptedNoteText).toBeInstanceOf(Uint8Array);
|
|
357
357
|
expect(encryptedNote).toMatchSnapshot();
|
|
358
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
358
359
|
const [_, decryptedNoteText] = await decryptNote(encryptedNote, {
|
|
359
360
|
content: encryptedNoteText,
|
|
360
361
|
type: 'gpgPassword',
|
package/encryption/encryption.js
CHANGED
|
@@ -27,6 +27,7 @@ export const decryptViaKeys = withCustomErrors(_decryptViaKeys);
|
|
|
27
27
|
export const encrypt = async (encryptionParams) => {
|
|
28
28
|
if (!encryptionParams.type ||
|
|
29
29
|
encryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.Disabled) {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
31
|
return encryptionParams.content;
|
|
31
32
|
}
|
|
32
33
|
const res = (encryptionParams.type ===
|
|
@@ -38,6 +39,7 @@ export const encrypt = async (encryptionParams) => {
|
|
|
38
39
|
export const decrypt = async (decryptionParams) => {
|
|
39
40
|
if (!decryptionParams.type ||
|
|
40
41
|
decryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.Disabled) {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
43
|
return decryptionParams.content;
|
|
42
44
|
}
|
|
43
45
|
const decryptedNote = (decryptionParams.type ===
|
|
@@ -52,6 +54,7 @@ async function _encryptViaPassword({ content, password, format = 'binary', }) {
|
|
|
52
54
|
});
|
|
53
55
|
const encryptedMessage = await _encrypt({
|
|
54
56
|
message,
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
58
|
format: format,
|
|
56
59
|
passwords: [password],
|
|
57
60
|
});
|
|
@@ -73,6 +76,7 @@ export async function _encryptViaKeys({ content, publicKey: armoredPublicKey, pr
|
|
|
73
76
|
: encryptedPrivateKey;
|
|
74
77
|
const encryptedMessage = await _encrypt({
|
|
75
78
|
message,
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
80
|
format: format,
|
|
77
81
|
encryptionKeys: publicKey,
|
|
78
82
|
signingKeys: privateKey,
|
package/models/command.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DefaultCommands } from './default-commands.js';
|
|
2
|
-
|
|
3
|
-
export type CommandGroup =
|
|
2
|
+
import { COMMAND_GROUPS } from '../constants/command-groups.contant.js';
|
|
3
|
+
export type CommandGroup = (typeof COMMAND_GROUPS)[number] | (string & Record<never, never>);
|
|
4
4
|
export interface CommandHandlerParams<T = any> {
|
|
5
5
|
event?: KeyboardEvent;
|
|
6
6
|
data?: T;
|
|
7
|
+
meta: CommandMeta<T>;
|
|
7
8
|
[key: string]: unknown;
|
|
8
9
|
}
|
|
9
10
|
export interface CommandPreview {
|
|
@@ -23,6 +24,6 @@ export interface CommandMeta<T = any> extends Partial<CommandPreview> {
|
|
|
23
24
|
[key: string]: T;
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
export interface Command<T = any> extends CommandMeta<T> {
|
|
27
|
-
handler: (params?: CommandHandlerParams) =>
|
|
27
|
+
export interface Command<T = any, R = unknown> extends CommandMeta<T> {
|
|
28
|
+
handler: (params?: CommandHandlerParams<T>) => R | Promise<R>;
|
|
28
29
|
}
|
package/models/command.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
package/models/file-system.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export interface FileSystem {
|
|
|
27
27
|
isDirExist: (path: string) => Promise<boolean>;
|
|
28
28
|
isFileExist: (path: string) => Promise<boolean>;
|
|
29
29
|
utimeSync: (path: string, atime?: string | number | Date, mtime?: string | number | Date) => Promise<void>;
|
|
30
|
+
init?: <T = unknown>(params?: T) => Promise<void>;
|
|
30
31
|
}
|
package/models/modal.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orgnote-api",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.7",
|
|
4
4
|
"description": "Official API for creating extensions for OrgNote app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"test": "vitest",
|
|
10
10
|
"build": "npm run clear && tspc --project tsconfig.json",
|
|
11
11
|
"clear": "rm -rf dist",
|
|
12
|
+
"lint": "eslint -c ./eslint.config.js \"./src*/**/*.{ts,js,cjs,mjs}\"",
|
|
12
13
|
"codegen:api": "openapi-generator-cli generate",
|
|
13
14
|
"codegen:css-doc": "node collect-css-variables.cjs --docs",
|
|
14
15
|
"codegen:css-types": "node collect-css-variables.cjs --types",
|
|
@@ -50,13 +51,17 @@
|
|
|
50
51
|
"vue-router": "4.2.5"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
54
|
+
"@eslint/js": "9.17.0",
|
|
53
55
|
"@openapitools/openapi-generator-cli": "2.13.4",
|
|
54
56
|
"@types/node": "20.13.0",
|
|
57
|
+
"eslint": "9.17.0",
|
|
55
58
|
"fix-esm-import-path": "1.10.0",
|
|
59
|
+
"globals": "15.14.0",
|
|
56
60
|
"ts-patch": "3.2.1",
|
|
57
|
-
"typescript": "
|
|
61
|
+
"typescript": "5.3.3",
|
|
62
|
+
"typescript-eslint": "8.18.1",
|
|
58
63
|
"typescript-transform-paths": "3.5.1",
|
|
59
64
|
"typescript-transformer-esm": "1.1.0",
|
|
60
|
-
"vitest": "
|
|
65
|
+
"vitest": "1.5.0"
|
|
61
66
|
}
|
|
62
67
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { isOrgGpgFile } from "./is-org-file.js";
|
|
2
|
-
export async function extendNotesFilesDiff(changes, readFile) {
|
|
3
|
-
const upsertedNotesFromLastSync = [
|
|
4
|
-
...changes.updated,
|
|
5
|
-
...changes.created,
|
|
6
|
-
];
|
|
7
|
-
const notesFromLastSync = [];
|
|
8
|
-
for (const nc of upsertedNotesFromLastSync) {
|
|
9
|
-
const encrypted = isOrgGpgFile(nc.filePath);
|
|
10
|
-
}
|
|
11
|
-
const noteIdsFromLastSync = new Set(notesFromLastSync.map((n) => n.id));
|
|
12
|
-
const deletedNotesIdsWithoutRename = changes.deleted.reduce((acc, nc) => {
|
|
13
|
-
if (!noteIdsFromLastSync.has(nc.id)) {
|
|
14
|
-
acc.push(nc.id);
|
|
15
|
-
}
|
|
16
|
-
return acc;
|
|
17
|
-
}, []);
|
|
18
|
-
return {
|
|
19
|
-
deletedNotesIds: deletedNotesIdsWithoutRename,
|
|
20
|
-
};
|
|
21
|
-
}
|