orgnote-api 0.42.3 → 0.42.6

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.
@@ -1,11 +1,12 @@
1
- import type { Ref } from 'vue';
2
- import { OrgNoteSettings } from './orgnote-config.js';
3
- import { StoreDefinition } from './store.js';
1
+ import type { Ref } from "vue";
2
+ import { OrgNoteSettings } from "./orgnote-config.js";
3
+ import { StoreDefinition } from "./store.js";
4
4
  import { ModelsAPIToken } from "../remote-api/index.js";
5
5
  export interface SettingsStore {
6
6
  settings: OrgNoteSettings;
7
7
  tokens: Ref<ModelsAPIToken[]>;
8
8
  onboardingCompleted: Ref<boolean>;
9
+ onboardingCurrentStep: Ref<number>;
9
10
  loadApiTokens: () => Promise<void>;
10
11
  createApiToken: () => Promise<void>;
11
12
  removeApiToken: (token: ModelsAPIToken) => Promise<void>;
@@ -10,6 +10,7 @@ export declare const SyncProfileSchema: import("valibot").ObjectSchema<{
10
10
  readonly debug: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, false>;
11
11
  readonly backupDir: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
12
12
  readonly backupCount: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 3>;
13
+ readonly ignorePatterns: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>, readonly []>;
13
14
  }, undefined>;
14
15
  export declare const SyncProfileConfigSchema: import("valibot").ObjectSchema<{
15
16
  readonly accounts: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
@@ -23,6 +24,7 @@ export declare const SyncProfileConfigSchema: import("valibot").ObjectSchema<{
23
24
  readonly debug: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, false>;
24
25
  readonly backupDir: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
25
26
  readonly backupCount: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 3>;
27
+ readonly ignorePatterns: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>, readonly []>;
26
28
  }, undefined>, undefined>, readonly []>;
27
29
  readonly root: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
28
30
  readonly name: import("valibot").StringSchema<undefined>;
@@ -35,6 +37,7 @@ export declare const SyncProfileConfigSchema: import("valibot").ObjectSchema<{
35
37
  readonly debug: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, false>;
36
38
  readonly backupDir: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
37
39
  readonly backupCount: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 3>;
40
+ readonly ignorePatterns: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>, readonly []>;
38
41
  }, undefined>, undefined>, readonly []>;
39
42
  }, undefined>;
40
43
  export type SyncProfile = InferOutput<typeof SyncProfileSchema>;
@@ -10,6 +10,7 @@ export const SyncProfileSchema = object({
10
10
  debug: optional(boolean(), false),
11
11
  backupDir: optional(string(), ''),
12
12
  backupCount: optional(number(), 3),
13
+ ignorePatterns: optional(array(string()), []),
13
14
  });
14
15
  export const SyncProfileConfigSchema = object({
15
16
  accounts: optional(array(SyncProfileSchema), []),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.42.3",
3
+ "version": "0.42.6",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -53,6 +53,7 @@
53
53
  "openpgp": "6.3.0",
54
54
  "org-mode-ast": "0.11.8",
55
55
  "partysocket": "1.1.6",
56
+ "picomatch": "4.0.4",
56
57
  "smol-toml": "1.5.2"
57
58
  },
58
59
  "devDependencies": {
@@ -61,6 +62,7 @@
61
62
  "@rollup/rollup-linux-arm64-gnu": "4.14.2",
62
63
  "@types/diff-match-patch": "^1.0.36",
63
64
  "@types/node": "22.14.1",
65
+ "@types/picomatch": "4.0.3",
64
66
  "eslint": "9.25.1",
65
67
  "eslint-plugin-sonarjs": "3.0.5",
66
68
  "fix-esm-import-path": "1.10.1",
package/sync/scan.js CHANGED
@@ -1,24 +1,30 @@
1
- import { toAbsolutePath } from "../utils/to-absolute-path.js";
2
- const DEFAULT_IGNORE = [
1
+ import { toAbsolutePath, toRelativePath } from "../utils/to-absolute-path.js";
2
+ import picomatch from 'picomatch';
3
+ const DEFAULT_IGNORE_PATTERNS = [
3
4
  '.git',
5
+ '.jj',
6
+ '.hg',
7
+ '.svn',
4
8
  '.DS_Store',
5
9
  'node_modules',
6
10
  '.sync-state',
7
11
  '.Trash',
8
12
  ];
13
+ const compileMatchers = (patterns) => patterns.map((p) => picomatch(p, { dot: true }));
9
14
  export async function scanLocalFiles(fs, rootPath, ignorePatterns = []) {
10
- const ignore = [...DEFAULT_IGNORE, ...ignorePatterns];
11
- return scanDir(fs, rootPath, ignore);
15
+ const allPatterns = [...DEFAULT_IGNORE_PATTERNS, ...ignorePatterns];
16
+ const matchers = compileMatchers(allPatterns);
17
+ return scanDir(fs, rootPath, matchers);
12
18
  }
13
- async function scanDir(fs, path, ignore) {
14
- const entries = await fs.readDir(path);
15
- const filteredEntries = entries.filter((e) => !shouldIgnore(e.name, ignore));
16
- const nestedResults = await Promise.all(filteredEntries.map((entry) => processEntry(fs, entry, ignore)));
19
+ async function scanDir(fs, dirPath, matchers) {
20
+ const entries = await fs.readDir(dirPath);
21
+ const filteredEntries = entries.filter((e) => !shouldIgnore(e.name, toRelativePath(e.path), matchers));
22
+ const nestedResults = await Promise.all(filteredEntries.map((entry) => processEntry(fs, entry, matchers)));
17
23
  return nestedResults.flat();
18
24
  }
19
- async function processEntry(fs, entry, ignore) {
25
+ async function processEntry(fs, entry, matchers) {
20
26
  if (entry.type === 'directory') {
21
- return scanDir(fs, entry.path, ignore);
27
+ return scanDir(fs, entry.path, matchers);
22
28
  }
23
29
  return [toLocalFile(entry)];
24
30
  }
@@ -27,13 +33,7 @@ const toLocalFile = (entry) => ({
27
33
  mtime: entry.mtime,
28
34
  size: entry.size,
29
35
  });
30
- const shouldIgnore = (name, patterns) => patterns.some((pattern) => matchPattern(pattern, name));
31
- const matchPattern = (pattern, name) => {
32
- if (!pattern.includes('*'))
33
- return name === pattern;
34
- const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
35
- return regex.test(name);
36
- };
36
+ const shouldIgnore = (name, relativePath, matchers) => matchers.some((match) => match(name) || match(relativePath));
37
37
  export const findDeletedLocally = (localFiles, stateData) => {
38
38
  const localPaths = new Set(localFiles.map((f) => f.path));
39
39
  return Object.keys(stateData.files).filter((path) => !localPaths.has(path));