orgnote-api 0.17.6 → 0.18.0

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/index.d.ts CHANGED
@@ -4,4 +4,5 @@ import type * as ast from 'org-mode-ast';
4
4
  export * from './encryption';
5
5
  export * from './tools';
6
6
  export * from './files-api';
7
+ export * from './mappers';
7
8
  export { ast };
package/index.js CHANGED
@@ -3,3 +3,4 @@ export * from './models';
3
3
  export * from './encryption';
4
4
  export * from './tools';
5
5
  export * from './files-api';
6
+ export * from './mappers';
@@ -0,0 +1 @@
1
+ export * from './orgnode-to-note';
@@ -0,0 +1 @@
1
+ export * from './orgnode-to-note';
@@ -0,0 +1,3 @@
1
+ import { OrgNode } from 'org-mode-ast';
2
+ import { FileInfo, Note } from "../models";
3
+ export declare function orgnodeToNote(orgnode: OrgNode, fileInfo: FileInfo): Note;
@@ -0,0 +1,11 @@
1
+ import { splitPath } from 'src/tools';
2
+ export function orgnodeToNote(orgnode, fileInfo) {
3
+ return {
4
+ id: orgnode.meta.id,
5
+ meta: orgnode.meta,
6
+ filePath: splitPath(fileInfo.path),
7
+ touchedAt: new Date(fileInfo.atime).toISOString(),
8
+ updatedAt: new Date(Math.max(fileInfo.mtime, fileInfo.ctime)).toISOString(),
9
+ createdAt: new Date(fileInfo.ctime).toISOString(),
10
+ };
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.17.6",
3
+ "version": "0.18.0",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -4,7 +4,7 @@ import { findNoteFilesDiff } from '../find-notes-files-diff';
4
4
  import { statSync } from 'fs';
5
5
  import { rmSync } from 'fs';
6
6
  import { getFileName } from '../get-file-name';
7
- import { join } from '../join';
7
+ import { join } from '../join-path';
8
8
  const testFilesFolder = 'src/tools/__tests__/miscellaneous/';
9
9
  const nestedFolder = 'nested-folder/';
10
10
  const fn = (fileName) => `${testFilesFolder}${fileName}`;
@@ -25,8 +25,3 @@ test('should handle array with multiple elements correctly', () => {
25
25
  const result = getStringPath(path);
26
26
  expect(result).toBe('this/is/a/test');
27
27
  });
28
- test('Should not take slashes from the path array into account.', () => {
29
- const path = ['/', 'this', '/', 'is-path', 'qwe'];
30
- const result = getStringPath(path);
31
- expect(result).toBe('this/is-path/qwe');
32
- });
@@ -1,5 +1,5 @@
1
1
  import { test, expect } from 'vitest';
2
- import { join } from '../join';
2
+ import { join } from '../join-path';
3
3
  test('Should join file paths', () => {
4
4
  const samples = [
5
5
  ['dir1', 'subdir2', 'file'],
@@ -12,3 +12,8 @@ test('Should join file paths', () => {
12
12
  expect(result).toMatchSnapshot();
13
13
  });
14
14
  });
15
+ test('Should not take slashes from the path array into account.', () => {
16
+ const path = ['/', 'this', '/', 'is-path', 'qwe'];
17
+ const result = join(...path);
18
+ expect(result).toBe('this/is-path/qwe');
19
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import { test, expect } from 'vitest';
2
+ import { splitPath } from 'src/tools';
3
+ test('Should correctly split various paths with different formats', () => {
4
+ const pathExpected = [
5
+ ['/some/long/path/file.txt', ['some', 'long', 'path', 'file.txt']],
6
+ ['/a/b/c/d.txt', ['a', 'b', 'c', 'd.txt']],
7
+ ['/singlefile.txt', ['singlefile.txt']],
8
+ ['/folder/', ['folder']],
9
+ ['relative/path/to/file', ['relative', 'path', 'to', 'file']],
10
+ ['/leading/slash/', ['leading', 'slash']],
11
+ ['no/leading/slash', ['no', 'leading', 'slash']],
12
+ ['/trailing/slash/', ['trailing', 'slash']],
13
+ ];
14
+ pathExpected.forEach(([path, expected]) => {
15
+ expect(splitPath(path)).toEqual(expected);
16
+ });
17
+ });
18
+ test('Should handle edge cases like empty paths or root', () => {
19
+ const pathExpected = [
20
+ ['', []],
21
+ ['/', []],
22
+ ['//', []],
23
+ ];
24
+ pathExpected.forEach(([path, expected]) => {
25
+ expect(splitPath(path)).toEqual(expected);
26
+ });
27
+ });
@@ -1,6 +1,6 @@
1
1
  import { getStringPath } from './get-string-path';
2
2
  import { isOrgFile } from './is-org-file';
3
- import { join } from './join';
3
+ import { join } from './join-path';
4
4
  export async function findNoteFilesDiff({ fileInfo, readDir, lastSync, storedNotesInfo, dirPath, }) {
5
5
  const orgFilePaths = await readOrgFilesRecursively({
6
6
  fileInfo,
package/tools/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from './is-org-file';
4
4
  export * from './get-string-path';
5
5
  export * from './get-file-name';
6
6
  export * from './find-notes-files-diff';
7
- export * from './join';
7
+ export * from './join-path';
8
+ export * from './split-path';
package/tools/index.js CHANGED
@@ -4,4 +4,5 @@ export * from './is-org-file';
4
4
  export * from './get-string-path';
5
5
  export * from './get-file-name';
6
6
  export * from './find-notes-files-diff';
7
- export * from './join';
7
+ export * from './join-path';
8
+ export * from './split-path';
@@ -0,0 +1 @@
1
+ export declare function splitPath(path: string): string[];
@@ -0,0 +1,3 @@
1
+ export function splitPath(path) {
2
+ return path.split('/').filter((x) => x !== '');
3
+ }
File without changes
File without changes