orgnote-api 0.8.4 → 0.10.1

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.ts CHANGED
@@ -68,6 +68,10 @@ export interface OrgNoteApi {
68
68
  ) => WidgetBuilder;
69
69
  };
70
70
  };
71
+ // Available only on mobile apps
72
+ fileSystem: {
73
+ readPath: () => Promise<string>;
74
+ };
71
75
  commands: {
72
76
  add(...commands: Command[]): void;
73
77
  remove(...commands: Command[]): void;
@@ -1,4 +1,7 @@
1
- import { ModelsPublicNote, ModelsPublicNoteEncryptedEnum } from '../remote-api';
1
+ import {
2
+ ModelsPublicNote,
3
+ ModelsPublicNoteEncryptionTypeEnum,
4
+ } from '../remote-api';
2
5
 
3
6
  import {
4
7
  decryptViaKeys,
@@ -9,10 +12,12 @@ import {
9
12
  import { OrgNoteEncryption } from '../models/encryption';
10
13
  import { parse, withMetaInfo } from 'org-mode-ast';
11
14
 
12
- export type NoteEncryptedType = `${ModelsPublicNote['encrypted']}`;
15
+ export type NoteEncryptionType = `${ModelsPublicNote['encryptionType']}`;
16
+
13
17
  export interface AbstractEncryptedNote {
14
18
  content: string;
15
- encrypted?: NoteEncryptedType;
19
+ encryptionType?: NoteEncryptionType;
20
+ encrypted?: boolean;
16
21
  meta: {
17
22
  [key: string]: any;
18
23
  published?: boolean;
@@ -24,7 +29,7 @@ export async function encryptNote<T extends AbstractEncryptedNote>(
24
29
  ): Promise<T> {
25
30
  if (
26
31
  !encryptionParams.type ||
27
- encryptionParams.type === ModelsPublicNoteEncryptedEnum.Disabled ||
32
+ encryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.Disabled ||
28
33
  note.meta.published
29
34
  ) {
30
35
  return note;
@@ -32,7 +37,7 @@ export async function encryptNote<T extends AbstractEncryptedNote>(
32
37
 
33
38
  note.meta = { id: note.meta.id, published: note.meta.published };
34
39
 
35
- if (encryptionParams.type === ModelsPublicNoteEncryptedEnum.GpgKeys) {
40
+ if (encryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.GpgKeys) {
36
41
  return await encryptNoteViaKeys(
37
42
  note,
38
43
  encryptionParams.publicKey,
@@ -50,7 +55,7 @@ export async function encryptNoteViaPassword<T extends AbstractEncryptedNote>(
50
55
  return {
51
56
  ...note,
52
57
  content,
53
- encrypted: ModelsPublicNoteEncryptedEnum.GpgPassword,
58
+ encrypted: ModelsPublicNoteEncryptionTypeEnum.GpgPassword,
54
59
  };
55
60
  }
56
61
 
@@ -70,7 +75,7 @@ export async function encryptNoteViaKeys<T extends AbstractEncryptedNote>(
70
75
  return {
71
76
  ...note,
72
77
  content,
73
- encrypted: ModelsPublicNoteEncryptedEnum.GpgKeys,
78
+ encrypted: ModelsPublicNoteEncryptionTypeEnum.GpgKeys,
74
79
  };
75
80
  }
76
81
 
@@ -82,12 +87,12 @@ export async function decryptNote<T extends AbstractEncryptedNote>(
82
87
  note.meta.published ||
83
88
  !note.encrypted ||
84
89
  !encryptionParams.type ||
85
- encryptionParams.type === ModelsPublicNoteEncryptedEnum.Disabled
90
+ encryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.Disabled
86
91
  ) {
87
92
  return note;
88
93
  }
89
94
  const decryptedNote =
90
- encryptionParams.type === ModelsPublicNoteEncryptedEnum.GpgKeys
95
+ encryptionParams.type === ModelsPublicNoteEncryptionTypeEnum.GpgKeys
91
96
  ? await decryptNoteViaKeys(
92
97
  note,
93
98
  encryptionParams.privateKey,
@@ -111,7 +116,7 @@ export async function decryptNoteViaPassword<T extends AbstractEncryptedNote>(
111
116
  return {
112
117
  ...note,
113
118
  content,
114
- encrypted: ModelsPublicNoteEncryptedEnum.GpgPassword,
119
+ encrypted: ModelsPublicNoteEncryptionTypeEnum.GpgPassword,
115
120
  };
116
121
  }
117
122
 
@@ -128,6 +133,6 @@ export async function decryptNoteViaKeys<T extends AbstractEncryptedNote>(
128
133
  return {
129
134
  ...note,
130
135
  content,
131
- encrypted: ModelsPublicNoteEncryptedEnum.GpgKeys,
136
+ encrypted: ModelsPublicNoteEncryptionTypeEnum.GpgKeys,
132
137
  };
133
138
  }
package/index.ts CHANGED
@@ -2,4 +2,5 @@ export * from './api';
2
2
  export * from './models';
3
3
  import type * as ast from 'org-mode-ast';
4
4
  export * from './encryption';
5
+ export * from './tools';
5
6
  export { ast };
package/models/command.ts CHANGED
@@ -30,6 +30,7 @@ export interface CommandMeta<T = any> extends Partial<CommandPreview> {
30
30
  group?: CommandGroup;
31
31
  allowOnInput?: boolean;
32
32
  ignorePrompt?: boolean;
33
+ interactive?: boolean;
33
34
  /* When command is system command, it will not be shown for users */
34
35
  system?: boolean;
35
36
  available?: () => boolean;
@@ -37,4 +37,8 @@ export enum DefaultCommands {
37
37
  OPEN_NOTE_VIEWER = 'view mode',
38
38
  OPEN_GRAPH = 'graph',
39
39
  OPEN_EXTENSIONS = 'extensions',
40
+
41
+ // Native mobile specific
42
+ SELECT_FILE_PATH = 'select file path',
43
+ PICK_SYNC_DIR = 'pick sync dir',
40
44
  }
@@ -1,19 +1,19 @@
1
- import type { ModelsPublicNoteEncryptedEnum } from '../remote-api';
1
+ import type { ModelsPublicNoteEncryptionTypeEnum } from '../remote-api';
2
2
 
3
3
  export interface OrgNoteGpgEncryption {
4
- type: typeof ModelsPublicNoteEncryptedEnum.GpgKeys;
4
+ type: typeof ModelsPublicNoteEncryptionTypeEnum.GpgKeys;
5
5
  privateKey: string;
6
6
  publicKey: string;
7
7
  privateKeyPassphrase?: string;
8
8
  }
9
9
 
10
10
  export interface OrgNotePasswordEncryption {
11
- type: typeof ModelsPublicNoteEncryptedEnum.GpgPassword;
11
+ type: typeof ModelsPublicNoteEncryptionTypeEnum.GpgPassword;
12
12
  password: string;
13
13
  }
14
14
 
15
15
  export interface OrgNoteDisabledEncryption {
16
- type: typeof ModelsPublicNoteEncryptedEnum.Disabled;
16
+ type: typeof ModelsPublicNoteEncryptionTypeEnum.Disabled;
17
17
  }
18
18
 
19
19
  export type OrgNoteEncryption =
package/models/note.ts CHANGED
@@ -16,9 +16,11 @@ export interface NotePreview {
16
16
  isMy: ModelsPublicNote['isMy'];
17
17
  author?: ModelsPublicUser;
18
18
  bookmarked?: boolean;
19
+ contentEncrypted?: boolean;
19
20
  }
20
21
 
21
22
  export interface Note extends ModelsPublicNote {
22
23
  deleted?: Date;
23
24
  bookmarked?: boolean;
25
+ contentEncrypted?: boolean;
24
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.8.4",
3
+ "version": "0.10.1",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -22,7 +22,8 @@
22
22
  "api.ts",
23
23
  "remote-api/**",
24
24
  "models/**",
25
- "encryption/**"
25
+ "encryption/**",
26
+ "tools/**"
26
27
  ],
27
28
  "exports": {
28
29
  ".": "./index.ts",
@@ -37,6 +38,7 @@
37
38
  },
38
39
  "homepage": "https://github.com/artawower/orgnote-api#readme",
39
40
  "dependencies": {
41
+ "@capacitor/filesystem": "6.0.0",
40
42
  "@codemirror/state": "6.4.1",
41
43
  "@codemirror/view": "6.26.3",
42
44
  "axios": "1.6.7",
@@ -47,6 +49,7 @@
47
49
  },
48
50
  "devDependencies": {
49
51
  "@openapitools/openapi-generator-cli": "2.9.0",
52
+ "@types/node": "20.13.0",
50
53
  "typescript": "^5.3.3",
51
54
  "vitest": "^1.5.0"
52
55
  }
package/remote-api/api.ts CHANGED
@@ -59,7 +59,7 @@ export interface HandlersCreatingNote {
59
59
  * @type {string}
60
60
  * @memberof HandlersCreatingNote
61
61
  */
62
- 'encrypted'?: HandlersCreatingNoteEncryptedEnum;
62
+ 'encryptionType'?: HandlersCreatingNoteEncryptionTypeEnum;
63
63
  /**
64
64
  *
65
65
  * @type {Array<string>}
@@ -92,12 +92,12 @@ export interface HandlersCreatingNote {
92
92
  'updatedAt'?: string;
93
93
  }
94
94
 
95
- export const HandlersCreatingNoteEncryptedEnum = {
95
+ export const HandlersCreatingNoteEncryptionTypeEnum = {
96
96
  Gpg: 'gpg',
97
97
  Password: 'password'
98
98
  } as const;
99
99
 
100
- export type HandlersCreatingNoteEncryptedEnum = typeof HandlersCreatingNoteEncryptedEnum[keyof typeof HandlersCreatingNoteEncryptedEnum];
100
+ export type HandlersCreatingNoteEncryptionTypeEnum = typeof HandlersCreatingNoteEncryptionTypeEnum[keyof typeof HandlersCreatingNoteEncryptionTypeEnum];
101
101
 
102
102
  /**
103
103
  *
@@ -616,7 +616,7 @@ export interface ModelsPublicNote {
616
616
  * @type {string}
617
617
  * @memberof ModelsPublicNote
618
618
  */
619
- 'encrypted'?: ModelsPublicNoteEncryptedEnum;
619
+ 'encryptionType'?: ModelsPublicNoteEncryptionTypeEnum;
620
620
  /**
621
621
  *
622
622
  * @type {Array<string>}
@@ -661,13 +661,13 @@ export interface ModelsPublicNote {
661
661
  'updatedAt'?: string;
662
662
  }
663
663
 
664
- export const ModelsPublicNoteEncryptedEnum = {
664
+ export const ModelsPublicNoteEncryptionTypeEnum = {
665
665
  GpgKeys: 'gpgKeys',
666
666
  GpgPassword: 'gpgPassword',
667
667
  Disabled: 'disabled'
668
668
  } as const;
669
669
 
670
- export type ModelsPublicNoteEncryptedEnum = typeof ModelsPublicNoteEncryptedEnum[keyof typeof ModelsPublicNoteEncryptedEnum];
670
+ export type ModelsPublicNoteEncryptionTypeEnum = typeof ModelsPublicNoteEncryptionTypeEnum[keyof typeof ModelsPublicNoteEncryptionTypeEnum];
671
671
 
672
672
  /**
673
673
  *
package/tools/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './mock-server';
@@ -0,0 +1,16 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ export const mockServer = <T extends (...params: any[]) => any>(
4
+ fn?: T,
5
+ defaultValue?: ReturnType<T>
6
+ ) => {
7
+ if (!fn) {
8
+ return (() => {}) as () => ReturnType<T>;
9
+ }
10
+ return (...params: Parameters<T>): ReturnType<T> => {
11
+ if (process.env.CLIENT) {
12
+ return fn(...params);
13
+ }
14
+ return defaultValue;
15
+ };
16
+ };