orgnote-api 0.41.24 → 0.41.26

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.
@@ -14,6 +14,23 @@ export interface CompletionSearchResult<T = unknown> {
14
14
  result: CompletionCandidate<T>[];
15
15
  }
16
16
  export type CandidateGetterFn<T = unknown> = (filter: string, limit?: number, offset?: number) => CompletionSearchResult<T> | Promise<CompletionSearchResult<T>>;
17
+ interface BaseCompletionConfig<T = unknown> {
18
+ name?: string;
19
+ searchAutocompletions?: string[];
20
+ placeholder?: string;
21
+ itemHeight?: number;
22
+ itemRenderer?: CompletionItemRenderer<T>;
23
+ searchText?: string;
24
+ onClicked?: (candidate: CompletionCandidate<T>) => void;
25
+ }
26
+ interface InputCompletionConfig<T = unknown> extends BaseCompletionConfig<T> {
27
+ type: 'input';
28
+ itemsGetter?: CandidateGetterFn<T>;
29
+ }
30
+ interface SearchCompletionConfig<T = unknown> extends BaseCompletionConfig<T> {
31
+ type?: 'choice' | 'input-choice';
32
+ itemsGetter: CandidateGetterFn<T>;
33
+ }
17
34
  export interface CompletionItemRendererProps<T = unknown> {
18
35
  candidate: CompletionCandidate<T>;
19
36
  index: number;
@@ -26,25 +43,15 @@ export type CompletionItemRenderer<T = unknown> = VueComponent & {
26
43
  $props: CompletionItemRendererProps<T>;
27
44
  };
28
45
  };
29
- export interface CompletionConfig<T = unknown> {
30
- name?: string;
31
- searchAutocompletions?: string[];
32
- itemsGetter: CandidateGetterFn<T>;
33
- type?: 'input' | 'choice' | 'input-choice';
34
- placeholder?: string;
35
- itemHeight?: number;
36
- itemRenderer?: CompletionItemRenderer<T>;
37
- searchText?: string;
38
- onClicked?: (candidate: CompletionCandidate<T>) => void;
39
- }
40
- export interface Completion<T = any, TResult = any> extends CompletionConfig<T> {
46
+ export type CompletionConfig<T = unknown> = InputCompletionConfig<T> | SearchCompletionConfig<T>;
47
+ export type Completion<T = any, TResult = any> = CompletionConfig<T> & {
41
48
  level?: number;
42
49
  candidates?: CompletionCandidate<T>[];
43
50
  selectedCandidateIndex?: number;
44
51
  total?: number;
45
52
  searchQuery: string;
46
53
  result: Promise<TResult>;
47
- }
54
+ };
48
55
  export interface CompletionInterceptorContext {
49
56
  completionName: string;
50
57
  searchQuery: string;
@@ -56,3 +63,4 @@ export interface CompletionInterceptor<T = unknown> {
56
63
  priority?: number;
57
64
  handler: (candidates: CompletionCandidate<T>[], context: CompletionInterceptorContext) => CompletionCandidate<T>[] | Promise<CompletionCandidate<T>[]>;
58
65
  }
66
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.41.24",
3
+ "version": "0.41.26",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -37,9 +37,17 @@
37
37
  "./constants": "./constants/index.js",
38
38
  "./sync": "./sync/index.js"
39
39
  },
40
- "files": ["**"],
40
+ "files": [
41
+ "**"
42
+ ],
41
43
  "types": "./index.d.ts",
42
- "keywords": ["orgnote", "org-mode", "org-roam", "api", "extensions"],
44
+ "keywords": [
45
+ "orgnote",
46
+ "org-mode",
47
+ "org-roam",
48
+ "api",
49
+ "extensions"
50
+ ],
43
51
  "author": "darkawower <app.orgnote@gmail.com> (https://org-note.com)",
44
52
  "license": "GPL-3.0-or-later",
45
53
  "bugs": {
@@ -81,4 +89,4 @@
81
89
  "vue": ">=3.0.0",
82
90
  "vue-router": ">=4.0.0"
83
91
  }
84
- }
92
+ }
@@ -1,19 +1,15 @@
1
1
  import { afterEach, beforeEach, expect, test } from 'vitest';
2
- import { mkdirSync, rmdirSync, statSync, utimesSync, writeFileSync } from 'fs';
2
+ import { mkdirSync, rmSync, statSync, utimesSync, writeFileSync } from 'fs';
3
3
  import { join } from 'path';
4
4
  import { findFilesDiff } from "../find-notes-files-diff.js";
5
5
  const testFilesFolder = 'src/utils/__tests__/miscellaneous2/';
6
6
  function initFiles() {
7
- mkdirSync(testFilesFolder);
8
- mkdirSync(testFilesFolder + '/nested-folder');
7
+ cleanFiles();
8
+ mkdirSync(testFilesFolder, { recursive: true });
9
+ mkdirSync(testFilesFolder + '/nested-folder', { recursive: true });
9
10
  }
10
11
  function cleanFiles() {
11
- try {
12
- rmdirSync(testFilesFolder, { recursive: true });
13
- }
14
- catch {
15
- return;
16
- }
12
+ rmSync(testFilesFolder, { recursive: true, force: true });
17
13
  }
18
14
  function createTestFile(content, fileName, updated) {
19
15
  const filePath = join(testFilesFolder, fileName);
@@ -77,7 +73,7 @@ test('Should find files diff when folder was renamed', () => {
77
73
  updatedAt: new Date('2021-01-01'),
78
74
  },
79
75
  ];
80
- rmdirSync(testFilesFolder + 'nested-folder', { recursive: true });
76
+ rmSync(testFilesFolder + 'nested-folder', { recursive: true, force: true });
81
77
  const changedFiles = findFilesDiff([], storedNoteInfos, (filePath) => new Date(statSync(filePath).mtime));
82
78
  expect(changedFiles).toMatchInlineSnapshot(`
83
79
  {
@@ -91,7 +87,7 @@ test('Should find files diff when folder was renamed', () => {
91
87
  `);
92
88
  });
93
89
  test('Should find created note when nested folder created', () => {
94
- mkdirSync(testFilesFolder + 'new-nested-folder');
90
+ mkdirSync(testFilesFolder + 'new-nested-folder', { recursive: true });
95
91
  createTestFile(`new nested file!`, 'new-nested-folder/org-file.org', new Date('2023-01-01'));
96
92
  const storedNoteInfos = [];
97
93
  const changedFiles = findFilesDiff([testFilesFolder + 'new-nested-folder/org-file.org'], storedNoteInfos, (filePath) => new Date(statSync(filePath).mtime));
@@ -1,4 +1,4 @@
1
- import { getFileName, getFileNameWithoutExtension } from "../get-file-name.js";
1
+ import { getFileName, getFileNameWithoutExtension, getFileExtension, } 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');
@@ -12,3 +12,12 @@ test('Should return file name without extension', () => {
12
12
  test('Should return file name without extension from path', () => {
13
13
  expect(getFileNameWithoutExtension('/some/path/foo.org')).toBe('foo');
14
14
  });
15
+ test('Should return extension from file name', () => {
16
+ expect(getFileExtension('foo.org')).toBe('org');
17
+ });
18
+ test('Should return extension from path', () => {
19
+ expect(getFileExtension('/some/path/foo.org')).toBe('org');
20
+ });
21
+ test('Should return empty extension when file has no extension', () => {
22
+ expect(getFileExtension('/some/path/README')).toBe('');
23
+ });
@@ -5,5 +5,9 @@ export const getFileNameWithoutExtension = (path) => {
5
5
  return getFileName(path).split('.').shift();
6
6
  };
7
7
  export const getFileExtension = (path) => {
8
- return getFileName(path).split('.').pop();
8
+ const fileName = getFileName(path);
9
+ const parts = fileName.split('.');
10
+ if (parts.length < 2)
11
+ return '';
12
+ return parts[parts.length - 1] ?? '';
9
13
  };