@chronicle.app/obsidian 0.3.0 → 0.5.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Extractor, Record } from '@chronicle.app/etl';
|
|
1
|
+
import { Extractor, Record, type Survey, type SurveyOptions } from '@chronicle.app/etl';
|
|
2
2
|
import ObsidianTransformer from './ObsidianTransformer.js';
|
|
3
3
|
export interface VaultNote {
|
|
4
4
|
/** Path relative to the enclosing vault, including .md. */
|
|
@@ -41,6 +41,8 @@ export declare class ObsidianExtractor extends Extractor<typeof ObsidianExtracto
|
|
|
41
41
|
protected asOfTime(): Date;
|
|
42
42
|
keyOf(record: Record): string | null;
|
|
43
43
|
determineCount(): Promise<number | null>;
|
|
44
|
+
/** The notes a run reads and when they were last edited, from the file list setup made. */
|
|
45
|
+
survey(options?: SurveyOptions): Promise<Survey>;
|
|
44
46
|
extract(): AsyncGenerator<Record>;
|
|
45
47
|
private readNote;
|
|
46
48
|
/** Ignore hidden files/directories and symlinks; only Markdown is imported. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { Extractor } from '@chronicle.app/etl';
|
|
3
|
+
import { Extractor, countMonth } from '@chronicle.app/etl';
|
|
4
4
|
import { load, CORE_SCHEMA } from 'js-yaml';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import ObsidianTransformer from './ObsidianTransformer.js';
|
|
@@ -85,6 +85,22 @@ export class ObsidianExtractor extends Extractor {
|
|
|
85
85
|
const limit = this.getEffectiveLimit();
|
|
86
86
|
return limit === null ? this.entries.length : Math.min(limit, this.entries.length);
|
|
87
87
|
}
|
|
88
|
+
/** The notes a run reads and when they were last edited, from the file list setup made. */
|
|
89
|
+
async survey(options = {}) {
|
|
90
|
+
// Newest first, so the ends are the latest and earliest edits.
|
|
91
|
+
const [newest, oldest] = [this.entries[0], this.entries.at(-1)];
|
|
92
|
+
const byMonth = {};
|
|
93
|
+
if (options.byMonth)
|
|
94
|
+
for (const entry of this.entries)
|
|
95
|
+
countMonth(byMonth, entry.mtime);
|
|
96
|
+
return {
|
|
97
|
+
notes: {
|
|
98
|
+
count: this.entries.length,
|
|
99
|
+
...(newest && oldest && { earliest: oldest.mtime, latest: newest.mtime }),
|
|
100
|
+
...(options.byMonth && { byMonth }),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
88
104
|
async *extract() {
|
|
89
105
|
let count = 0;
|
|
90
106
|
for (const entry of this.entries) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Locator, type Candidate, type LocationMatch } from '@chronicle.app/etl';
|
|
2
|
+
/**
|
|
3
|
+
* The vaults Obsidian has opened, from its registry, `obsidian.json`: one
|
|
4
|
+
* candidate each, its folder the run's input. A vault Obsidian remembers
|
|
5
|
+
* but that has since moved or gone isn't found, so it isn't offered.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ObsidianLocator extends Locator {
|
|
8
|
+
static source: string;
|
|
9
|
+
static strategy: string;
|
|
10
|
+
locate(matches: LocationMatch[]): AsyncGenerator<Candidate>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ObsidianLocator.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { Locator } from '@chronicle.app/etl';
|
|
4
|
+
/**
|
|
5
|
+
* The vaults Obsidian has opened, from its registry, `obsidian.json`: one
|
|
6
|
+
* candidate each, its folder the run's input. A vault Obsidian remembers
|
|
7
|
+
* but that has since moved or gone isn't found, so it isn't offered.
|
|
8
|
+
*/
|
|
9
|
+
export class ObsidianLocator extends Locator {
|
|
10
|
+
static source = 'obsidian';
|
|
11
|
+
static strategy = 'vault';
|
|
12
|
+
async *locate(matches) {
|
|
13
|
+
for (const match of matches) {
|
|
14
|
+
let vaults;
|
|
15
|
+
try {
|
|
16
|
+
vaults = JSON.parse(await readFile(match.path, 'utf8'))?.vaults ?? {};
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
for (const vault of Object.values(vaults)) {
|
|
22
|
+
if (typeof vault?.path !== 'string')
|
|
23
|
+
continue;
|
|
24
|
+
const { home } = this.context;
|
|
25
|
+
const where = vault.path.startsWith(home + path.sep)
|
|
26
|
+
? `~${vault.path.slice(home.length)}`
|
|
27
|
+
: vault.path;
|
|
28
|
+
yield {
|
|
29
|
+
label: where,
|
|
30
|
+
config: { input: vault.path },
|
|
31
|
+
path: vault.path,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chronicle.app/obsidian",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"description": "Chronicle plugin for Obsidian Markdown documents and note links",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@chronicle.app/etl": "0.
|
|
26
|
-
"@chronicle.app/schema": "0.
|
|
27
|
-
"@chronicle.app/tsconfig": "0.
|
|
25
|
+
"@chronicle.app/etl": "0.5.0",
|
|
26
|
+
"@chronicle.app/schema": "0.5.0",
|
|
27
|
+
"@chronicle.app/tsconfig": "0.5.0",
|
|
28
28
|
"@types/js-yaml": "^4.0.9",
|
|
29
29
|
"@types/node": "^22.10.1",
|
|
30
30
|
"typescript": "^5.7.2"
|
|
@@ -66,10 +66,29 @@
|
|
|
66
66
|
"recordTypes": [
|
|
67
67
|
"notes"
|
|
68
68
|
],
|
|
69
|
-
"default": true
|
|
69
|
+
"default": true,
|
|
70
|
+
"locations": [
|
|
71
|
+
{
|
|
72
|
+
"path": "~/Library/Application Support/obsidian/obsidian.json",
|
|
73
|
+
"platforms": [
|
|
74
|
+
"darwin"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "~/.config/obsidian/obsidian.json",
|
|
79
|
+
"platforms": [
|
|
80
|
+
"linux"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
]
|
|
70
84
|
}
|
|
71
85
|
}
|
|
72
86
|
}
|
|
87
|
+
},
|
|
88
|
+
"deepLinks": {
|
|
89
|
+
"obsidian": {
|
|
90
|
+
"*": "obsidian://open?vault={inRealm.handle}&file={handle}"
|
|
91
|
+
}
|
|
73
92
|
}
|
|
74
93
|
}
|
|
75
94
|
}
|