@cueloop/integration-obsidian 0.1.0-alpha.63 → 0.1.0-alpha.64

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 (2) hide show
  1. package/package.json +4 -3
  2. package/src/detect.ts +6 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cueloop/integration-obsidian",
3
- "version": "0.1.0-alpha.63",
3
+ "version": "0.1.0-alpha.64",
4
4
  "description": "Export reviewed cueloop plans into an Obsidian vault",
5
5
  "homepage": "https://github.com/mmurakaru/cueloop#readme",
6
6
  "bugs": {
@@ -24,8 +24,9 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@cueloop/extension-api": "0.1.0-alpha.63",
28
- "@cueloop/schema": "0.1.0-alpha.63"
27
+ "@cueloop/extension-api": "0.1.0-alpha.64",
28
+ "@cueloop/schema": "0.1.0-alpha.64",
29
+ "valibot": "^1.4.2"
29
30
  },
30
31
  "engines": {
31
32
  "bun": ">=1.3.0"
package/src/detect.ts CHANGED
@@ -7,6 +7,11 @@
7
7
  import { existsSync, readFileSync } from "node:fs";
8
8
  import { homedir } from "node:os";
9
9
  import { join } from "node:path";
10
+ import * as v from "valibot";
11
+
12
+ const ObsidianRegistrySchema = v.object({
13
+ vaults: v.optional(v.record(v.string(), v.object({ path: v.optional(v.string()) }))),
14
+ });
10
15
 
11
16
  /** Platform-specific location of Obsidian's own obsidian.json. */
12
17
  export function obsidianConfigPath(platform: NodeJS.Platform = process.platform): string {
@@ -31,9 +36,7 @@ export function obsidianConfigPath(platform: NodeJS.Platform = process.platform)
31
36
  /** Vault paths registered with Obsidian that exist on disk. */
32
37
  export function detectVaults(configPath: string = obsidianConfigPath()): string[] {
33
38
  try {
34
- const raw = JSON.parse(readFileSync(configPath, "utf8")) as {
35
- vaults?: Record<string, { path?: string }>;
36
- };
39
+ const raw = v.parse(ObsidianRegistrySchema, JSON.parse(readFileSync(configPath, "utf8")));
37
40
 
38
41
  return Object.values(raw.vaults ?? {})
39
42
  .map((vault) => vault.path)