orgnote-api 0.17.0 → 0.17.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.
Files changed (126) hide show
  1. package/dist/api.d.ts +112 -0
  2. package/dist/api.js +1 -0
  3. package/dist/encryption/__tests__/encryption-keys.d.ts +3 -0
  4. package/{encryption/__tests__/encryption-keys.ts → dist/encryption/__tests__/encryption-keys.js} +0 -2
  5. package/dist/encryption/__tests__/encryption.spec.d.ts +1 -0
  6. package/dist/encryption/__tests__/encryption.spec.js +287 -0
  7. package/dist/encryption/__tests__/note-encryption.spec.d.ts +1 -0
  8. package/dist/encryption/__tests__/note-encryption.spec.js +364 -0
  9. package/dist/encryption/encryption.d.ts +27 -0
  10. package/dist/encryption/encryption.js +156 -0
  11. package/dist/encryption/index.js +2 -0
  12. package/dist/encryption/note-encryption.d.ts +12 -0
  13. package/dist/encryption/note-encryption.js +42 -0
  14. package/dist/files-api.d.ts +7 -0
  15. package/dist/files-api.js +22 -0
  16. package/dist/index.js +5 -0
  17. package/dist/models/command.d.ts +29 -0
  18. package/dist/models/command.js +1 -0
  19. package/dist/models/completion.d.ts +22 -0
  20. package/dist/models/completion.js +1 -0
  21. package/dist/models/default-commands.d.ts +30 -0
  22. package/dist/models/default-commands.js +41 -0
  23. package/dist/models/editor.d.ts +23 -0
  24. package/dist/models/editor.js +1 -0
  25. package/dist/models/encryption.d.ts +31 -0
  26. package/dist/models/encryption.js +1 -0
  27. package/dist/models/extension.d.ts +34 -0
  28. package/dist/models/extension.js +1 -0
  29. package/dist/models/file-system.d.ts +23 -0
  30. package/dist/models/file-system.js +1 -0
  31. package/{models/index.ts → dist/models/index.d.ts} +2 -0
  32. package/dist/models/index.js +13 -0
  33. package/dist/models/modal.d.ts +10 -0
  34. package/dist/models/modal.js +1 -0
  35. package/dist/models/note.d.ts +23 -0
  36. package/dist/models/note.js +1 -0
  37. package/dist/models/sync.d.ts +34 -0
  38. package/dist/models/sync.js +1 -0
  39. package/dist/models/theme-variables.d.ts +192 -0
  40. package/dist/models/theme-variables.js +194 -0
  41. package/{models/vue-component.ts → dist/models/vue-component.d.ts} +1 -1
  42. package/dist/models/vue-component.js +1 -0
  43. package/dist/models/widget-type.d.ts +5 -0
  44. package/dist/models/widget-type.js +6 -0
  45. package/dist/models/widget.d.ts +51 -0
  46. package/dist/models/widget.js +1 -0
  47. package/dist/remote-api/api.d.ts +1525 -0
  48. package/{remote-api/api.ts → dist/remote-api/api.js} +246 -1149
  49. package/dist/remote-api/base.d.ts +66 -0
  50. package/{remote-api/base.ts → dist/remote-api/base.js} +13 -36
  51. package/dist/remote-api/common.d.ts +65 -0
  52. package/{remote-api/common.ts → dist/remote-api/common.js} +31 -48
  53. package/{remote-api/configuration.ts → dist/remote-api/configuration.d.ts} +3 -22
  54. package/dist/remote-api/configuration.js +95 -0
  55. package/dist/remote-api/index.d.ts +13 -0
  56. package/{remote-api/index.ts → dist/remote-api/index.js} +0 -3
  57. package/dist/tools/__tests__/find-files-diff.spec.d.ts +1 -0
  58. package/dist/tools/__tests__/find-files-diff.spec.js +110 -0
  59. package/dist/tools/__tests__/find-note-files-diff.spec.d.ts +1 -0
  60. package/dist/tools/__tests__/find-note-files-diff.spec.js +168 -0
  61. package/dist/tools/__tests__/get-file-name.spec.d.ts +1 -0
  62. package/dist/tools/__tests__/get-file-name.spec.js +14 -0
  63. package/dist/tools/__tests__/get-string-path.spec.d.ts +1 -0
  64. package/dist/tools/__tests__/get-string-path.spec.js +27 -0
  65. package/dist/tools/__tests__/is-gpg-encrypted.spec.d.ts +1 -0
  66. package/{tools/__tests__/is-gpg-encrypted.spec.ts → dist/tools/__tests__/is-gpg-encrypted.spec.js} +4 -8
  67. package/dist/tools/__tests__/is-org-file.spec.d.ts +1 -0
  68. package/dist/tools/__tests__/is-org-file.spec.js +54 -0
  69. package/dist/tools/__tests__/join.spec.d.ts +1 -0
  70. package/dist/tools/__tests__/join.spec.js +14 -0
  71. package/dist/tools/__tests__/read-org-files-recursively.spec.d.ts +1 -0
  72. package/dist/tools/__tests__/read-org-files-recursively.spec.js +51 -0
  73. package/dist/tools/extend-notes-files-diff.d.ts +3 -0
  74. package/dist/tools/extend-notes-files-diff.js +21 -0
  75. package/dist/tools/find-notes-files-diff.d.ts +5 -0
  76. package/dist/tools/find-notes-files-diff.js +108 -0
  77. package/dist/tools/get-file-name.d.ts +2 -0
  78. package/dist/tools/get-file-name.js +6 -0
  79. package/dist/tools/get-string-path.d.ts +1 -0
  80. package/dist/tools/get-string-path.js +6 -0
  81. package/dist/tools/index.d.ts +6 -0
  82. package/dist/tools/index.js +6 -0
  83. package/dist/tools/is-gpg-encrypted.d.ts +1 -0
  84. package/dist/tools/is-gpg-encrypted.js +6 -0
  85. package/dist/tools/is-org-file.d.ts +2 -0
  86. package/dist/tools/is-org-file.js +4 -0
  87. package/dist/tools/join.d.ts +1 -0
  88. package/dist/tools/join.js +3 -0
  89. package/dist/tools/mock-server.d.ts +1 -0
  90. package/dist/tools/mock-server.js +12 -0
  91. package/package.json +6 -14
  92. package/api.ts +0 -123
  93. package/encryption/__tests__/__snapshots__/note-encryption.spec.ts.snap +0 -231
  94. package/encryption/__tests__/encryption.spec.ts +0 -352
  95. package/encryption/__tests__/note-encryption.spec.ts +0 -425
  96. package/encryption/encryption.ts +0 -264
  97. package/encryption/note-encryption.ts +0 -77
  98. package/files-api.ts +0 -25
  99. package/models/command.ts +0 -45
  100. package/models/completion.ts +0 -30
  101. package/models/default-commands.ts +0 -44
  102. package/models/editor.ts +0 -27
  103. package/models/encryption.ts +0 -50
  104. package/models/extension.ts +0 -45
  105. package/models/modal.ts +0 -12
  106. package/models/note.ts +0 -26
  107. package/models/theme-variables.ts +0 -194
  108. package/models/widget-type.ts +0 -5
  109. package/models/widget.ts +0 -59
  110. package/remote-api/.gitignore +0 -4
  111. package/remote-api/.npmignore +0 -1
  112. package/remote-api/.openapi-generator/FILES +0 -8
  113. package/remote-api/.openapi-generator/VERSION +0 -1
  114. package/remote-api/.openapi-generator-ignore +0 -23
  115. package/remote-api/git_push.sh +0 -57
  116. package/tools/__tests__/find-notes-files-diff.spec.ts +0 -176
  117. package/tools/__tests__/get-string-path.spec.ts +0 -32
  118. package/tools/__tests__/is-org-file.spec.ts +0 -62
  119. package/tools/find-notes-files-diff.ts +0 -48
  120. package/tools/get-string-path.ts +0 -6
  121. package/tools/index.ts +0 -3
  122. package/tools/is-gpg-encrypted.ts +0 -6
  123. package/tools/is-org-file.ts +0 -7
  124. package/tools/mock-server.ts +0 -16
  125. /package/{encryption/index.ts → dist/encryption/index.d.ts} +0 -0
  126. /package/{index.ts → dist/index.d.ts} +0 -0
@@ -1,23 +0,0 @@
1
- # OpenAPI Generator Ignore
2
- # Generated by openapi-generator https://github.com/openapitools/openapi-generator
3
-
4
- # Use this file to prevent files from being overwritten by the generator.
5
- # The patterns follow closely to .gitignore or .dockerignore.
6
-
7
- # As an example, the C# client generator defines ApiClient.cs.
8
- # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9
- #ApiClient.cs
10
-
11
- # You can match any string of characters against a directory, file or extension with a single asterisk (*):
12
- #foo/*/qux
13
- # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14
-
15
- # You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16
- #foo/**/qux
17
- # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18
-
19
- # You can also negate patterns with an exclamation (!).
20
- # For example, you can ignore all files in a docs folder with the file extension .md:
21
- #docs/*.md
22
- # Then explicitly reverse the ignore rule for a single file:
23
- #!docs/README.md
@@ -1,57 +0,0 @@
1
- #!/bin/sh
2
- # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
- #
4
- # Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
5
-
6
- git_user_id=$1
7
- git_repo_id=$2
8
- release_note=$3
9
- git_host=$4
10
-
11
- if [ "$git_host" = "" ]; then
12
- git_host="github.com"
13
- echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14
- fi
15
-
16
- if [ "$git_user_id" = "" ]; then
17
- git_user_id="GIT_USER_ID"
18
- echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
- fi
20
-
21
- if [ "$git_repo_id" = "" ]; then
22
- git_repo_id="GIT_REPO_ID"
23
- echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
- fi
25
-
26
- if [ "$release_note" = "" ]; then
27
- release_note="Minor update"
28
- echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29
- fi
30
-
31
- # Initialize the local directory as a Git repository
32
- git init
33
-
34
- # Adds the files in the local repository and stages them for commit.
35
- git add .
36
-
37
- # Commits the tracked changes and prepares them to be pushed to a remote repository.
38
- git commit -m "$release_note"
39
-
40
- # Sets the new remote
41
- git_remote=$(git remote)
42
- if [ "$git_remote" = "" ]; then # git remote not defined
43
-
44
- if [ "$GIT_TOKEN" = "" ]; then
45
- echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46
- git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47
- else
48
- git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
49
- fi
50
-
51
- fi
52
-
53
- git pull origin master
54
-
55
- # Pushes (Forces) the changes in the local repository up to the remote repository
56
- echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57
- git push origin master 2>&1 | grep -v 'To https'
@@ -1,176 +0,0 @@
1
- import { afterEach, beforeEach, expect, test } from 'vitest';
2
- import { mkdirSync, rmdirSync, statSync, utimesSync, writeFileSync } from 'fs';
3
- import { join } from 'path';
4
- import { findNotesFilesDiff, StoredNoteInfo } from '../find-notes-files-diff';
5
-
6
- const testFilesFolder = 'src/tools/__tests__/miscellaneous/';
7
-
8
- function initFiles(): void {
9
- mkdirSync(testFilesFolder);
10
- mkdirSync(testFilesFolder + '/nested-folder');
11
- }
12
-
13
- function cleanFiles(): void {
14
- try {
15
- rmdirSync(testFilesFolder, { recursive: true });
16
- } catch (e) {}
17
- }
18
-
19
- function createTestFile(
20
- content: string,
21
- fileName: string,
22
- updated: Date
23
- ): void {
24
- const filePath = join(testFilesFolder, fileName);
25
-
26
- writeFileSync(filePath, content);
27
-
28
- const time = updated.getTime() / 1000; // Convert to seconds
29
- utimesSync(filePath, time, time);
30
- }
31
-
32
- beforeEach(() => initFiles());
33
- afterEach(() => cleanFiles());
34
-
35
- test('Should find files diff', () => {
36
- createTestFile(`unchanged file!`, 'org-file.org', new Date('2021-01-01'));
37
- createTestFile(
38
- `changed org file 2!`,
39
- 'org-file2.org',
40
- new Date('2022-01-01')
41
- );
42
- createTestFile(
43
- `deleted org in the nested folder file!`,
44
- 'nested-folder/org-file3.org',
45
- new Date('2021-01-01')
46
- );
47
- createTestFile(
48
- `created file in the nested folder!`,
49
- 'nested-folder/org-file4.org',
50
- new Date('2021-02-01')
51
- );
52
-
53
- const storedNoteInfos: StoredNoteInfo[] = [
54
- {
55
- filePath: [testFilesFolder + 'deleted-org-file.org'],
56
- id: 'deleted-org-file.org',
57
- updatedAt: new Date('2021-01-01'),
58
- },
59
- {
60
- filePath: [testFilesFolder + 'org-file.org'],
61
- id: 'org-file.org',
62
- updatedAt: new Date('2021-01-01'),
63
- },
64
- {
65
- filePath: [testFilesFolder + 'org-file2.org'],
66
- id: 'org-file2.org',
67
- updatedAt: new Date('2021-01-01'),
68
- },
69
- {
70
- filePath: [testFilesFolder + 'nested-folder/org-file3.org'],
71
- id: 'nested-folder/org-file3.org',
72
- updatedAt: new Date('2021-01-01'),
73
- },
74
- ];
75
-
76
- const changedFiles = findNotesFilesDiff(
77
- [
78
- testFilesFolder + 'org-file.org',
79
- testFilesFolder + 'org-file2.org',
80
- testFilesFolder + 'nested-folder/org-file3.org',
81
- testFilesFolder + 'nested-folder/org-file4.org',
82
- ],
83
- storedNoteInfos,
84
- (filePath: string) => new Date(statSync(filePath).mtime)
85
- );
86
-
87
- expect(changedFiles).toEqual({
88
- created: [testFilesFolder + 'nested-folder/org-file4.org'],
89
- updated: [testFilesFolder + 'org-file2.org'],
90
- deleted: [testFilesFolder + 'deleted-org-file.org'],
91
- });
92
- });
93
-
94
- test('Should find files diff when folder was renamed', () => {
95
- createTestFile(
96
- `nested file!`,
97
- 'nested-folder/org-file.org',
98
- new Date('2021-01-01')
99
- );
100
- createTestFile(
101
- `nested file2!`,
102
- 'nested-folder/org-file-2.org',
103
- new Date('2021-01-01')
104
- );
105
-
106
- const storedNoteInfos: StoredNoteInfo[] = [
107
- {
108
- filePath: [testFilesFolder + 'nested-folder/org-file.org'],
109
- id: 'nested-folder/org-file.org',
110
- updatedAt: new Date('2021-01-01'),
111
- },
112
- {
113
- filePath: [testFilesFolder + 'nested-folder/org-file2.org'],
114
- id: 'nested-folder/org-file2.org',
115
- updatedAt: new Date('2021-01-01'),
116
- },
117
- ];
118
-
119
- rmdirSync(testFilesFolder + 'nested-folder', { recursive: true });
120
-
121
- const changedFiles = findNotesFilesDiff(
122
- [],
123
- storedNoteInfos,
124
- (filePath: string) => new Date(statSync(filePath).mtime)
125
- );
126
-
127
- expect(changedFiles).toMatchInlineSnapshot(`
128
- {
129
- "created": [],
130
- "deleted": [
131
- "src/tools/__tests__/miscellaneous/nested-folder/org-file.org",
132
- "src/tools/__tests__/miscellaneous/nested-folder/org-file2.org",
133
- ],
134
- "updated": [],
135
- }
136
- `);
137
- });
138
-
139
- test('Should find created note when nested folder created', () => {
140
- mkdirSync(testFilesFolder + 'new-nested-folder');
141
- createTestFile(
142
- `new nested file!`,
143
- 'new-nested-folder/org-file.org',
144
- new Date('2023-01-01')
145
- );
146
-
147
- const storedNoteInfos: StoredNoteInfo[] = [];
148
-
149
- const changedFiles = findNotesFilesDiff(
150
- [testFilesFolder + 'new-nested-folder/org-file.org'],
151
- storedNoteInfos,
152
- (filePath: string) => new Date(statSync(filePath).mtime)
153
- );
154
-
155
- expect(changedFiles).toEqual({
156
- created: [testFilesFolder + 'new-nested-folder/org-file.org'],
157
- updated: [],
158
- deleted: [],
159
- });
160
- });
161
-
162
- test('Should find nothing when no files provided', () => {
163
- const storedNoteInfos: StoredNoteInfo[] = [];
164
-
165
- const changedFiles = findNotesFilesDiff(
166
- [],
167
- storedNoteInfos,
168
- (filePath: string) => new Date(statSync(filePath).mtime)
169
- );
170
-
171
- expect(changedFiles).toEqual({
172
- created: [],
173
- updated: [],
174
- deleted: [],
175
- });
176
- });
@@ -1,32 +0,0 @@
1
- import { getStringPath } from '../get-string-path';
2
- import { test, expect } from 'vitest';
3
-
4
- test('should return the same string if path is a string', () => {
5
- const path = 'some/path';
6
- const result = getStringPath(path);
7
- expect(result).toBe('some/path');
8
- });
9
-
10
- test('should join array elements with "/" if path is an array', () => {
11
- const path = ['some', 'path'];
12
- const result = getStringPath(path);
13
- expect(result).toBe('some/path');
14
- });
15
-
16
- test('should return an empty string if path is an empty array', () => {
17
- const path: string[] = [];
18
- const result = getStringPath(path);
19
- expect(result).toBe('');
20
- });
21
-
22
- test('should handle array with one element correctly', () => {
23
- const path = ['single'];
24
- const result = getStringPath(path);
25
- expect(result).toBe('single');
26
- });
27
-
28
- test('should handle array with multiple elements correctly', () => {
29
- const path = ['this', 'is', 'a', 'test'];
30
- const result = getStringPath(path);
31
- expect(result).toBe('this/is/a/test');
32
- });
@@ -1,62 +0,0 @@
1
- import { test, expect } from 'vitest';
2
- import { isOrgFile, isOrgGpgFile } from '../is-org-file';
3
-
4
- test('Should return true for org files', () => {
5
- const files = [
6
- 'myNote.org',
7
- 'my_note.org',
8
- '123.org',
9
- 'some_long_note#4123$123eqasdasd.org.gpg',
10
- 'some_long_note#4123$123eqasdasd.org',
11
- 'note with space.org',
12
- 'note with space.org.gpg',
13
- ];
14
-
15
- files.forEach((file) => {
16
- expect(isOrgFile(file), file).toBe(true);
17
- });
18
- });
19
-
20
- test('Should not return true for non-org files', () => {
21
- const files = [
22
- 'myNote.md',
23
- 'my_note.md',
24
- '123.md',
25
- 'some_long_note#4123$123eqasdas',
26
- 'note.org.file',
27
- 'org',
28
- 'org.',
29
- 'text.gpg',
30
- ];
31
-
32
- files.forEach((file) => {
33
- expect(isOrgFile(file), file).toBe(false);
34
- });
35
- });
36
-
37
- test('Should return true for org.gpg files', () => {
38
- const gpgFiles = [
39
- 'myNote.org.gpg',
40
- 'my_note.org.gpg',
41
- '123.org.gpg',
42
- 'org.org.gpg',
43
- 'gp_org.org.gpg',
44
- ];
45
-
46
- gpgFiles.forEach((file) => {
47
- expect(isOrgGpgFile(file), file).toBe(true);
48
- });
49
- });
50
-
51
- test('Should not return true for not .org.gpg files', () => {
52
- const notGpgFiles = [
53
- 'myNote.org',
54
- 'my_note.org',
55
- '123.org',
56
- 'some_gpg_file.txt',
57
- ];
58
-
59
- notGpgFiles.forEach((file) => {
60
- expect(isOrgGpgFile(file), file).toBe(false);
61
- });
62
- });
@@ -1,48 +0,0 @@
1
- import { getStringPath } from './get-string-path';
2
-
3
- export interface ChangedFiles {
4
- deleted: string[];
5
- created: string[];
6
- updated: string[];
7
- }
8
-
9
- export interface StoredNoteInfo {
10
- filePath: string[];
11
- id: string;
12
- updatedAt: string | Date;
13
- }
14
-
15
- export function findNotesFilesDiff(
16
- filePaths: string[],
17
- storedNotesInfo: StoredNoteInfo[],
18
- updatedTimeGetter: (filePath: string) => Date
19
- ): ChangedFiles {
20
- const existingFilePaths = new Set<string>(filePaths);
21
-
22
- const storedNotesPathSet = new Set<string>(
23
- storedNotesInfo.map((n) => getStringPath(n.filePath))
24
- );
25
- const changedFiles: ChangedFiles = { deleted: [], created: [], updated: [] };
26
-
27
- storedNotesInfo.forEach((storedNote) => {
28
- const fullPath = getStringPath(storedNote.filePath);
29
- if (!existingFilePaths.has(fullPath)) {
30
- changedFiles.deleted.push(fullPath);
31
- return;
32
- }
33
-
34
- const updatedTime = updatedTimeGetter(fullPath);
35
- if (updatedTime > new Date(storedNote.updatedAt)) {
36
- changedFiles.updated.push(fullPath);
37
- }
38
- });
39
-
40
- filePaths.forEach((filePath) => {
41
- if (!storedNotesPathSet.has(filePath)) {
42
- changedFiles.created.push(filePath);
43
- return;
44
- }
45
- });
46
-
47
- return changedFiles;
48
- }
@@ -1,6 +0,0 @@
1
- export function getStringPath(path: string | string[]): string {
2
- if (Array.isArray(path)) {
3
- return `${path.join('/')}`;
4
- }
5
- return path;
6
- }
package/tools/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './mock-server';
2
- export * from './is-gpg-encrypted';
3
- export * from './is-org-file';
@@ -1,6 +0,0 @@
1
- export function isGpgEncrypted(text: string | Uint8Array): boolean {
2
- if (text instanceof Uint8Array) {
3
- return true;
4
- }
5
- return text.startsWith('-----BEGIN PGP MESSAGE-----');
6
- }
@@ -1,7 +0,0 @@
1
- const orgFileExtenstionRegex = /\.org(\.gpg)?$/;
2
- export const isOrgFile = (fileName: string): boolean =>
3
- orgFileExtenstionRegex.test(fileName);
4
-
5
- const orgGpgFileExtenstionRegex = /\.org\.gpg$/;
6
- export const isOrgGpgFile = (fileName: string): boolean =>
7
- orgGpgFileExtenstionRegex.test(fileName);
@@ -1,16 +0,0 @@
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
- };
File without changes