orgnote-api 0.19.5 → 0.19.8

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 CHANGED
@@ -1,16 +1,16 @@
1
1
 
2
2
  # Table of Contents
3
3
 
4
- 1. [Introduction](#orged65399)
5
- 2. [Connected links](#orgc368352)
6
- 3. [Extension structure](#org1370386)
7
- 1. [Folder structure](#org6a7f73b)
8
- 2. [Extension entrypoint](#orge2d0f79)
9
- 3. [Extension manifest](#org1e76d43)
10
- 4. [Extension API](#orgbb09389)
11
- 4. [Publish to official repository](#orgdd94657)
12
- 5. [Extensions example](#orgf459c20)
13
- 6. [Contribute guide](#org383a272)
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='https://wakatime.com/badge/github/Artawower/orgnote-api'><img src='https://wakatime.com/badge/github/Artawower/orgnote-api.svg' alt='wakatime'></a>
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
- <a href='https://github.com/artawower/orgnote-api/actions/workflows/melpazoid.yml/badge.svg'><img src='https://github.com/artawower/orgnote-api/actions/workflows/melpazoid.yml/badge.svg' alt='ci' /></a>
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="orged65399"></a>
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="orgc368352"></a>
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="org1370386"></a>
88
+ <a id="org995dbfb"></a>
69
89
 
70
90
  # Extension structure
71
91
 
72
92
 
73
- <a id="org6a7f73b"></a>
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="orge2d0f79"></a>
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="org1e76d43"></a>
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="orgbb09389"></a>
146
+ <a id="org222bab3"></a>
127
147
 
128
148
  ## Extension API
129
149
 
130
150
 
131
- <a id="orgdd94657"></a>
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="orgf459c20"></a>
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="org383a272"></a>
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](./CONTRIBUTE.md) before contributing to avoid misunderstandings!
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';
@@ -0,0 +1 @@
1
+ export * from './command-groups.contant.js';
@@ -0,0 +1 @@
1
+ export * from "./command-groups.contant.js";
@@ -329,7 +329,7 @@ KeknNUbrK5etSQFysC2pNdVkQ/HGG4uPnjR+6dppQ7kdJDjwRmw1WcYNlQ==
329
329
  -----END PGP MESSAGE-----
330
330
  `;
331
331
  try {
332
- const decryptedMessage = await decrypt({
332
+ await decrypt({
333
333
  content: armoredContent,
334
334
  type: 'gpgPassword',
335
335
  format: 'utf8',
@@ -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',
@@ -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/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from './encryption/index.js';
5
5
  export * from './tools/index.js';
6
6
  export * from './files-api.js';
7
7
  export * from './mappers/index.js';
8
+ export * from './constants/index.js';
8
9
  export { ast };
package/index.js CHANGED
@@ -4,3 +4,4 @@ export * from "./encryption/index.js";
4
4
  export * from "./tools/index.js";
5
5
  export * from "./files-api.js";
6
6
  export * from "./mappers/index.js";
7
+ export * from "./constants/index.js";
@@ -1,9 +1,10 @@
1
1
  import { DefaultCommands } from './default-commands.js';
2
- export declare const DEFAULT_KEYBINDING_GROUP = "default";
3
- export type CommandGroup = 'settings' | 'editor' | 'global' | 'note-detail' | 'completion' | string;
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) => unknown | Promise<unknown>;
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 const DEFAULT_KEYBINDING_GROUP = 'default';
1
+ export {};
@@ -27,5 +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 = any>(params?: T) => Promise<void>;
30
+ init?: <T = unknown>(params?: T) => Promise<void>;
31
31
  }
package/models/modal.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VueComponent } from './vue-component.js';
2
- export interface ModalConfig<T = any> {
2
+ export interface ModalConfig<T = unknown> {
3
3
  closable?: boolean;
4
4
  title?: string;
5
5
  modalProps?: T;
@@ -1,3 +1,3 @@
1
1
  export type VueComponent = {
2
2
  __name: string;
3
- } & any;
3
+ } & Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.19.5",
3
+ "version": "0.19.8",
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",
@@ -27,19 +28,12 @@
27
28
  "./encryption": "./encryption/index.js",
28
29
  "./tools": "./tools/index.js",
29
30
  "./mappers": "./mappers/index.js",
30
- "./commands": "./commands/index.js"
31
+ "./commands": "./commands/index.js",
32
+ "./constants": "./constants/index.js"
31
33
  },
32
- "files": [
33
- "**"
34
- ],
34
+ "files": ["**"],
35
35
  "types": "./index.d.ts",
36
- "keywords": [
37
- "orgnote",
38
- "org-mode",
39
- "org-roam",
40
- "api",
41
- "extensions"
42
- ],
36
+ "keywords": ["orgnote", "org-mode", "org-roam", "api", "extensions"],
43
37
  "author": "darkawower <app.orgnote@gmail.com> (https://org-note.com)",
44
38
  "license": "GPL-3.0-or-later",
45
39
  "bugs": {
@@ -58,13 +52,17 @@
58
52
  "vue-router": "4.2.5"
59
53
  },
60
54
  "devDependencies": {
55
+ "@eslint/js": "9.17.0",
61
56
  "@openapitools/openapi-generator-cli": "2.13.4",
62
57
  "@types/node": "20.13.0",
58
+ "eslint": "9.17.0",
63
59
  "fix-esm-import-path": "1.10.0",
60
+ "globals": "15.14.0",
64
61
  "ts-patch": "3.2.1",
65
- "typescript": "^5.3.3",
62
+ "typescript": "5.3.3",
63
+ "typescript-eslint": "8.18.1",
66
64
  "typescript-transform-paths": "3.5.1",
67
65
  "typescript-transformer-esm": "1.1.0",
68
- "vitest": "^1.5.0"
66
+ "vitest": "1.5.0"
69
67
  }
70
68
  }
@@ -11,7 +11,9 @@ function cleanFiles() {
11
11
  try {
12
12
  rmdirSync(testFilesFolder, { recursive: true });
13
13
  }
14
- catch (e) { }
14
+ catch {
15
+ return;
16
+ }
15
17
  }
16
18
  function createTestFile(content, fileName, updated) {
17
19
  const filePath = join(testFilesFolder, fileName);
@@ -17,7 +17,9 @@ function cleanFiles() {
17
17
  try {
18
18
  rmSync(testFilesFolder, { recursive: true });
19
19
  }
20
- catch (e) { }
20
+ catch {
21
+ return;
22
+ }
21
23
  }
22
24
  function createTestFile(filePath, updated, content) {
23
25
  writeFileSync(filePath, content);
@@ -1,3 +0,0 @@
1
- import { HandlersSyncNotesRequest } from "../remote-api/index.js";
2
- import { NoteChanges, FileSystem } from '../models/index.js';
3
- export declare function extendNotesFilesDiff(changes: NoteChanges, readFile: FileSystem['readFile']): Promise<HandlersSyncNotesRequest>;
@@ -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
- }