trilium-api 1.0.0 → 1.0.1
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/.github/workflows/ci.yml +37 -37
- package/.github/workflows/publish.yml +84 -86
- package/LICENSE +660 -660
- package/README.md +835 -836
- package/package.json +15 -13
- package/src/client.test.ts +477 -477
- package/src/client.ts +91 -91
- package/src/demo-mapper.ts +166 -166
- package/src/demo-search.ts +108 -108
- package/src/demo.ts +126 -126
- package/src/index.ts +34 -34
- package/src/mapper.test.ts +638 -638
- package/src/mapper.ts +534 -534
- package/tsconfig.json +42 -42
package/src/demo-search.ts
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Demo script for the Search Query Builder
|
|
3
|
-
*
|
|
4
|
-
* This demonstrates how to use buildSearchQuery to construct
|
|
5
|
-
* type-safe Trilium search queries.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* pnpm tsx src/demo-search.ts
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { buildSearchQuery } from './mapper.js';
|
|
12
|
-
|
|
13
|
-
console.log('Search Query Builder Demo');
|
|
14
|
-
console.log('='.repeat(50));
|
|
15
|
-
console.log();
|
|
16
|
-
|
|
17
|
-
// Simple label search
|
|
18
|
-
console.log('1. Simple label search:');
|
|
19
|
-
console.log(' Code: buildSearchQuery({ "#blog": true })');
|
|
20
|
-
console.log(' Result:', buildSearchQuery({ '#blog': true }));
|
|
21
|
-
console.log();
|
|
22
|
-
|
|
23
|
-
// Label with value
|
|
24
|
-
console.log('2. Label with value:');
|
|
25
|
-
console.log(' Code: buildSearchQuery({ "#status": "published" })');
|
|
26
|
-
console.log(' Result:', buildSearchQuery({ '#status': 'published' }));
|
|
27
|
-
console.log();
|
|
28
|
-
|
|
29
|
-
// Label absence check
|
|
30
|
-
console.log('3. Label absence check:');
|
|
31
|
-
console.log(' Code: buildSearchQuery({ "#draft": false })');
|
|
32
|
-
console.log(' Result:', buildSearchQuery({ '#draft': false }));
|
|
33
|
-
console.log();
|
|
34
|
-
|
|
35
|
-
// Comparison operators
|
|
36
|
-
console.log('4. Comparison operators:');
|
|
37
|
-
console.log(' Code: buildSearchQuery({ "#wordCount": { value: 1000, operator: ">=" } })');
|
|
38
|
-
console.log(' Result:', buildSearchQuery({ '#wordCount': { value: 1000, operator: '>=' } }));
|
|
39
|
-
console.log();
|
|
40
|
-
|
|
41
|
-
// Note properties
|
|
42
|
-
console.log('5. Note properties:');
|
|
43
|
-
console.log(' Code: buildSearchQuery({ "note.type": "text", title: { value: "Blog", operator: "*=" } })');
|
|
44
|
-
console.log(
|
|
45
|
-
' Result:',
|
|
46
|
-
buildSearchQuery({ 'note.type': 'text', title: { value: 'Blog', operator: '*=' } })
|
|
47
|
-
);
|
|
48
|
-
console.log();
|
|
49
|
-
|
|
50
|
-
// Relations
|
|
51
|
-
console.log('6. Relations:');
|
|
52
|
-
console.log(' Code: buildSearchQuery({ "~author": "John" })');
|
|
53
|
-
console.log(' Result:', buildSearchQuery({ '~author': 'John' }));
|
|
54
|
-
console.log();
|
|
55
|
-
|
|
56
|
-
// AND conditions
|
|
57
|
-
console.log('7. AND conditions:');
|
|
58
|
-
console.log(' Code: buildSearchQuery({ AND: [{ "#blog": true }, { "#published": true }] })');
|
|
59
|
-
console.log(' Result:', buildSearchQuery({ AND: [{ '#blog': true }, { '#published': true }] }));
|
|
60
|
-
console.log();
|
|
61
|
-
|
|
62
|
-
// OR conditions
|
|
63
|
-
console.log('8. OR conditions:');
|
|
64
|
-
console.log(' Code: buildSearchQuery({ OR: [{ "#status": "published" }, { "#status": "featured" }] })');
|
|
65
|
-
console.log(
|
|
66
|
-
' Result:',
|
|
67
|
-
buildSearchQuery({ OR: [{ '#status': 'published' }, { '#status': 'featured' }] })
|
|
68
|
-
);
|
|
69
|
-
console.log();
|
|
70
|
-
|
|
71
|
-
// Complex nested conditions
|
|
72
|
-
console.log('9. Complex nested conditions:');
|
|
73
|
-
const complexQuery = {
|
|
74
|
-
AND: [
|
|
75
|
-
{ '#blog': true },
|
|
76
|
-
{
|
|
77
|
-
OR: [{ '#status': 'published' }, { '#status': 'featured' }],
|
|
78
|
-
},
|
|
79
|
-
{ '#wordCount': { value: 500, operator: '>=' as const } },
|
|
80
|
-
],
|
|
81
|
-
};
|
|
82
|
-
console.log(' Code: buildSearchQuery({');
|
|
83
|
-
console.log(' AND: [');
|
|
84
|
-
console.log(' { "#blog": true },');
|
|
85
|
-
console.log(' { OR: [{ "#status": "published" }, { "#status": "featured" }] },');
|
|
86
|
-
console.log(' { "#wordCount": { value: 500, operator: ">=" } }');
|
|
87
|
-
console.log(' ]');
|
|
88
|
-
console.log(' })');
|
|
89
|
-
console.log(' Result:', buildSearchQuery(complexQuery));
|
|
90
|
-
console.log();
|
|
91
|
-
|
|
92
|
-
// NOT conditions
|
|
93
|
-
console.log('10. NOT conditions:');
|
|
94
|
-
console.log(' Code: buildSearchQuery({ NOT: { "#archived": true } })');
|
|
95
|
-
console.log(' Result:', buildSearchQuery({ NOT: { '#archived': true } }));
|
|
96
|
-
console.log();
|
|
97
|
-
|
|
98
|
-
// Multiple conditions (implicit AND)
|
|
99
|
-
console.log('11. Multiple conditions (implicit AND):');
|
|
100
|
-
console.log(' Code: buildSearchQuery({ "#blog": true, "#published": true, "note.type": "text" })');
|
|
101
|
-
console.log(
|
|
102
|
-
' Result:',
|
|
103
|
-
buildSearchQuery({ '#blog': true, '#published': true, 'note.type': 'text' })
|
|
104
|
-
);
|
|
105
|
-
console.log();
|
|
106
|
-
|
|
107
|
-
console.log('='.repeat(50));
|
|
108
|
-
console.log('Demo completed!');
|
|
1
|
+
/**
|
|
2
|
+
* Demo script for the Search Query Builder
|
|
3
|
+
*
|
|
4
|
+
* This demonstrates how to use buildSearchQuery to construct
|
|
5
|
+
* type-safe Trilium search queries.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* pnpm tsx src/demo-search.ts
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { buildSearchQuery } from './mapper.js';
|
|
12
|
+
|
|
13
|
+
console.log('Search Query Builder Demo');
|
|
14
|
+
console.log('='.repeat(50));
|
|
15
|
+
console.log();
|
|
16
|
+
|
|
17
|
+
// Simple label search
|
|
18
|
+
console.log('1. Simple label search:');
|
|
19
|
+
console.log(' Code: buildSearchQuery({ "#blog": true })');
|
|
20
|
+
console.log(' Result:', buildSearchQuery({ '#blog': true }));
|
|
21
|
+
console.log();
|
|
22
|
+
|
|
23
|
+
// Label with value
|
|
24
|
+
console.log('2. Label with value:');
|
|
25
|
+
console.log(' Code: buildSearchQuery({ "#status": "published" })');
|
|
26
|
+
console.log(' Result:', buildSearchQuery({ '#status': 'published' }));
|
|
27
|
+
console.log();
|
|
28
|
+
|
|
29
|
+
// Label absence check
|
|
30
|
+
console.log('3. Label absence check:');
|
|
31
|
+
console.log(' Code: buildSearchQuery({ "#draft": false })');
|
|
32
|
+
console.log(' Result:', buildSearchQuery({ '#draft': false }));
|
|
33
|
+
console.log();
|
|
34
|
+
|
|
35
|
+
// Comparison operators
|
|
36
|
+
console.log('4. Comparison operators:');
|
|
37
|
+
console.log(' Code: buildSearchQuery({ "#wordCount": { value: 1000, operator: ">=" } })');
|
|
38
|
+
console.log(' Result:', buildSearchQuery({ '#wordCount': { value: 1000, operator: '>=' } }));
|
|
39
|
+
console.log();
|
|
40
|
+
|
|
41
|
+
// Note properties
|
|
42
|
+
console.log('5. Note properties:');
|
|
43
|
+
console.log(' Code: buildSearchQuery({ "note.type": "text", title: { value: "Blog", operator: "*=" } })');
|
|
44
|
+
console.log(
|
|
45
|
+
' Result:',
|
|
46
|
+
buildSearchQuery({ 'note.type': 'text', title: { value: 'Blog', operator: '*=' } })
|
|
47
|
+
);
|
|
48
|
+
console.log();
|
|
49
|
+
|
|
50
|
+
// Relations
|
|
51
|
+
console.log('6. Relations:');
|
|
52
|
+
console.log(' Code: buildSearchQuery({ "~author": "John" })');
|
|
53
|
+
console.log(' Result:', buildSearchQuery({ '~author': 'John' }));
|
|
54
|
+
console.log();
|
|
55
|
+
|
|
56
|
+
// AND conditions
|
|
57
|
+
console.log('7. AND conditions:');
|
|
58
|
+
console.log(' Code: buildSearchQuery({ AND: [{ "#blog": true }, { "#published": true }] })');
|
|
59
|
+
console.log(' Result:', buildSearchQuery({ AND: [{ '#blog': true }, { '#published': true }] }));
|
|
60
|
+
console.log();
|
|
61
|
+
|
|
62
|
+
// OR conditions
|
|
63
|
+
console.log('8. OR conditions:');
|
|
64
|
+
console.log(' Code: buildSearchQuery({ OR: [{ "#status": "published" }, { "#status": "featured" }] })');
|
|
65
|
+
console.log(
|
|
66
|
+
' Result:',
|
|
67
|
+
buildSearchQuery({ OR: [{ '#status': 'published' }, { '#status': 'featured' }] })
|
|
68
|
+
);
|
|
69
|
+
console.log();
|
|
70
|
+
|
|
71
|
+
// Complex nested conditions
|
|
72
|
+
console.log('9. Complex nested conditions:');
|
|
73
|
+
const complexQuery = {
|
|
74
|
+
AND: [
|
|
75
|
+
{ '#blog': true },
|
|
76
|
+
{
|
|
77
|
+
OR: [{ '#status': 'published' }, { '#status': 'featured' }],
|
|
78
|
+
},
|
|
79
|
+
{ '#wordCount': { value: 500, operator: '>=' as const } },
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
console.log(' Code: buildSearchQuery({');
|
|
83
|
+
console.log(' AND: [');
|
|
84
|
+
console.log(' { "#blog": true },');
|
|
85
|
+
console.log(' { OR: [{ "#status": "published" }, { "#status": "featured" }] },');
|
|
86
|
+
console.log(' { "#wordCount": { value: 500, operator: ">=" } }');
|
|
87
|
+
console.log(' ]');
|
|
88
|
+
console.log(' })');
|
|
89
|
+
console.log(' Result:', buildSearchQuery(complexQuery));
|
|
90
|
+
console.log();
|
|
91
|
+
|
|
92
|
+
// NOT conditions
|
|
93
|
+
console.log('10. NOT conditions:');
|
|
94
|
+
console.log(' Code: buildSearchQuery({ NOT: { "#archived": true } })');
|
|
95
|
+
console.log(' Result:', buildSearchQuery({ NOT: { '#archived': true } }));
|
|
96
|
+
console.log();
|
|
97
|
+
|
|
98
|
+
// Multiple conditions (implicit AND)
|
|
99
|
+
console.log('11. Multiple conditions (implicit AND):');
|
|
100
|
+
console.log(' Code: buildSearchQuery({ "#blog": true, "#published": true, "note.type": "text" })');
|
|
101
|
+
console.log(
|
|
102
|
+
' Result:',
|
|
103
|
+
buildSearchQuery({ '#blog': true, '#published': true, 'note.type': 'text' })
|
|
104
|
+
);
|
|
105
|
+
console.log();
|
|
106
|
+
|
|
107
|
+
console.log('='.repeat(50));
|
|
108
|
+
console.log('Demo completed!');
|
package/src/demo.ts
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Demo script to test connecting to a local Trilium instance
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* pnpm tsx src/demo.ts
|
|
6
|
-
*
|
|
7
|
-
* Make sure to set your ETAPI token below or via environment variable:
|
|
8
|
-
* TRILIUM_API_KEY=your-token pnpm tsx src/demo.ts
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { createTriliumClient, type TriliumNote } from './client.js';
|
|
12
|
-
|
|
13
|
-
const TRILIUM_URL = process.env.TRILIUM_URL || 'http://localhost:8080';
|
|
14
|
-
const TRILIUM_API_KEY = process.env.TRILIUM_API_KEY || 'YOUR_ETAPI_TOKEN_HERE';
|
|
15
|
-
const MAX_DEPTH = parseInt(process.env.MAX_DEPTH || '3', 10);
|
|
16
|
-
|
|
17
|
-
type Client = ReturnType<typeof createTriliumClient>;
|
|
18
|
-
|
|
19
|
-
async function printNoteTree(
|
|
20
|
-
client: Client,
|
|
21
|
-
noteId: string,
|
|
22
|
-
depth: number = 0,
|
|
23
|
-
prefix: string = '',
|
|
24
|
-
isLast: boolean = true
|
|
25
|
-
): Promise<void> {
|
|
26
|
-
if (depth > MAX_DEPTH) {
|
|
27
|
-
console.log(`${prefix}${isLast ? '└── ' : '├── '}...`);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const { data: note, error } = await client.GET('/notes/{noteId}', {
|
|
32
|
-
params: { path: { noteId } },
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (error || !note) {
|
|
36
|
-
console.log(`${prefix}${isLast ? '└── ' : '├── '}[Error fetching note]`);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const icon = getTypeIcon(note.type);
|
|
41
|
-
const connector = depth === 0 ? '' : isLast ? '└── ' : '├── ';
|
|
42
|
-
console.log(`${prefix}${connector}${icon} ${note.title || '(untitled)'}`);
|
|
43
|
-
|
|
44
|
-
const childIds = note.childNoteIds || [];
|
|
45
|
-
if (childIds.length === 0) return;
|
|
46
|
-
|
|
47
|
-
const newPrefix = depth === 0 ? '' : prefix + (isLast ? ' ' : '│ ');
|
|
48
|
-
|
|
49
|
-
for (let i = 0; i < childIds.length; i++) {
|
|
50
|
-
const childId = childIds[i];
|
|
51
|
-
if (!childId) continue;
|
|
52
|
-
const isLastChild = i === childIds.length - 1;
|
|
53
|
-
await printNoteTree(client, childId, depth + 1, newPrefix, isLastChild);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getTypeIcon(type: TriliumNote['type']): string {
|
|
58
|
-
switch (type) {
|
|
59
|
-
case 'text':
|
|
60
|
-
return '📄';
|
|
61
|
-
case 'code':
|
|
62
|
-
return '💻';
|
|
63
|
-
case 'image':
|
|
64
|
-
return '🖼️';
|
|
65
|
-
case 'search':
|
|
66
|
-
return '🔍';
|
|
67
|
-
case 'book':
|
|
68
|
-
return '📚';
|
|
69
|
-
case 'noteMap':
|
|
70
|
-
return '🗺️';
|
|
71
|
-
case 'mermaid':
|
|
72
|
-
return '📊';
|
|
73
|
-
case 'webView':
|
|
74
|
-
return '🌐';
|
|
75
|
-
case 'launcher':
|
|
76
|
-
return '🚀';
|
|
77
|
-
case 'doc':
|
|
78
|
-
return '📝';
|
|
79
|
-
case 'contentWidget':
|
|
80
|
-
return '🧩';
|
|
81
|
-
case 'relationMap':
|
|
82
|
-
return '🔗';
|
|
83
|
-
case 'render':
|
|
84
|
-
return '⚡';
|
|
85
|
-
case 'file':
|
|
86
|
-
return '📎';
|
|
87
|
-
default:
|
|
88
|
-
return '📁';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async function main() {
|
|
93
|
-
console.log('🔌 Connecting to Trilium at:', TRILIUM_URL);
|
|
94
|
-
console.log();
|
|
95
|
-
|
|
96
|
-
const client = createTriliumClient({
|
|
97
|
-
baseUrl: TRILIUM_URL,
|
|
98
|
-
apiKey: TRILIUM_API_KEY,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Get app info
|
|
102
|
-
const { data: appInfo, error: appError } = await client.GET('/app-info');
|
|
103
|
-
|
|
104
|
-
if (appError) {
|
|
105
|
-
console.error('❌ Failed to connect:', appError);
|
|
106
|
-
console.error('\nMake sure:');
|
|
107
|
-
console.error(' 1. Trilium is running at', TRILIUM_URL);
|
|
108
|
-
console.error(' 2. Your ETAPI token is correct');
|
|
109
|
-
console.error(' 3. ETAPI is enabled in Trilium settings');
|
|
110
|
-
process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
console.log('✅ Connected to Trilium', appInfo?.appVersion);
|
|
114
|
-
console.log();
|
|
115
|
-
|
|
116
|
-
// Print tree view
|
|
117
|
-
console.log(`📂 Note Tree (max depth: ${MAX_DEPTH}):`);
|
|
118
|
-
console.log('─'.repeat(40));
|
|
119
|
-
await printNoteTree(client, 'root');
|
|
120
|
-
console.log('─'.repeat(40));
|
|
121
|
-
|
|
122
|
-
console.log();
|
|
123
|
-
console.log('🎉 Done! Set MAX_DEPTH env var to see more levels.');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
main().catch(console.error);
|
|
1
|
+
/**
|
|
2
|
+
* Demo script to test connecting to a local Trilium instance
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* pnpm tsx src/demo.ts
|
|
6
|
+
*
|
|
7
|
+
* Make sure to set your ETAPI token below or via environment variable:
|
|
8
|
+
* TRILIUM_API_KEY=your-token pnpm tsx src/demo.ts
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { createTriliumClient, type TriliumNote } from './client.js';
|
|
12
|
+
|
|
13
|
+
const TRILIUM_URL = process.env.TRILIUM_URL || 'http://localhost:8080';
|
|
14
|
+
const TRILIUM_API_KEY = process.env.TRILIUM_API_KEY || 'YOUR_ETAPI_TOKEN_HERE';
|
|
15
|
+
const MAX_DEPTH = parseInt(process.env.MAX_DEPTH || '3', 10);
|
|
16
|
+
|
|
17
|
+
type Client = ReturnType<typeof createTriliumClient>;
|
|
18
|
+
|
|
19
|
+
async function printNoteTree(
|
|
20
|
+
client: Client,
|
|
21
|
+
noteId: string,
|
|
22
|
+
depth: number = 0,
|
|
23
|
+
prefix: string = '',
|
|
24
|
+
isLast: boolean = true
|
|
25
|
+
): Promise<void> {
|
|
26
|
+
if (depth > MAX_DEPTH) {
|
|
27
|
+
console.log(`${prefix}${isLast ? '└── ' : '├── '}...`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { data: note, error } = await client.GET('/notes/{noteId}', {
|
|
32
|
+
params: { path: { noteId } },
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (error || !note) {
|
|
36
|
+
console.log(`${prefix}${isLast ? '└── ' : '├── '}[Error fetching note]`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const icon = getTypeIcon(note.type);
|
|
41
|
+
const connector = depth === 0 ? '' : isLast ? '└── ' : '├── ';
|
|
42
|
+
console.log(`${prefix}${connector}${icon} ${note.title || '(untitled)'}`);
|
|
43
|
+
|
|
44
|
+
const childIds = note.childNoteIds || [];
|
|
45
|
+
if (childIds.length === 0) return;
|
|
46
|
+
|
|
47
|
+
const newPrefix = depth === 0 ? '' : prefix + (isLast ? ' ' : '│ ');
|
|
48
|
+
|
|
49
|
+
for (let i = 0; i < childIds.length; i++) {
|
|
50
|
+
const childId = childIds[i];
|
|
51
|
+
if (!childId) continue;
|
|
52
|
+
const isLastChild = i === childIds.length - 1;
|
|
53
|
+
await printNoteTree(client, childId, depth + 1, newPrefix, isLastChild);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getTypeIcon(type: TriliumNote['type']): string {
|
|
58
|
+
switch (type) {
|
|
59
|
+
case 'text':
|
|
60
|
+
return '📄';
|
|
61
|
+
case 'code':
|
|
62
|
+
return '💻';
|
|
63
|
+
case 'image':
|
|
64
|
+
return '🖼️';
|
|
65
|
+
case 'search':
|
|
66
|
+
return '🔍';
|
|
67
|
+
case 'book':
|
|
68
|
+
return '📚';
|
|
69
|
+
case 'noteMap':
|
|
70
|
+
return '🗺️';
|
|
71
|
+
case 'mermaid':
|
|
72
|
+
return '📊';
|
|
73
|
+
case 'webView':
|
|
74
|
+
return '🌐';
|
|
75
|
+
case 'launcher':
|
|
76
|
+
return '🚀';
|
|
77
|
+
case 'doc':
|
|
78
|
+
return '📝';
|
|
79
|
+
case 'contentWidget':
|
|
80
|
+
return '🧩';
|
|
81
|
+
case 'relationMap':
|
|
82
|
+
return '🔗';
|
|
83
|
+
case 'render':
|
|
84
|
+
return '⚡';
|
|
85
|
+
case 'file':
|
|
86
|
+
return '📎';
|
|
87
|
+
default:
|
|
88
|
+
return '📁';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function main() {
|
|
93
|
+
console.log('🔌 Connecting to Trilium at:', TRILIUM_URL);
|
|
94
|
+
console.log();
|
|
95
|
+
|
|
96
|
+
const client = createTriliumClient({
|
|
97
|
+
baseUrl: TRILIUM_URL,
|
|
98
|
+
apiKey: TRILIUM_API_KEY,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Get app info
|
|
102
|
+
const { data: appInfo, error: appError } = await client.GET('/app-info');
|
|
103
|
+
|
|
104
|
+
if (appError) {
|
|
105
|
+
console.error('❌ Failed to connect:', appError);
|
|
106
|
+
console.error('\nMake sure:');
|
|
107
|
+
console.error(' 1. Trilium is running at', TRILIUM_URL);
|
|
108
|
+
console.error(' 2. Your ETAPI token is correct');
|
|
109
|
+
console.error(' 3. ETAPI is enabled in Trilium settings');
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
console.log('✅ Connected to Trilium', appInfo?.appVersion);
|
|
114
|
+
console.log();
|
|
115
|
+
|
|
116
|
+
// Print tree view
|
|
117
|
+
console.log(`📂 Note Tree (max depth: ${MAX_DEPTH}):`);
|
|
118
|
+
console.log('─'.repeat(40));
|
|
119
|
+
await printNoteTree(client, 'root');
|
|
120
|
+
console.log('─'.repeat(40));
|
|
121
|
+
|
|
122
|
+
console.log();
|
|
123
|
+
console.log('🎉 Done! Set MAX_DEPTH env var to see more levels.');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
main().catch(console.error);
|
package/src/index.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
// Main exports for the Trilium API client
|
|
2
|
-
export {
|
|
3
|
-
createTriliumClient,
|
|
4
|
-
default as createClient,
|
|
5
|
-
// Mapper utilities
|
|
6
|
-
TriliumMapper,
|
|
7
|
-
buildSearchQuery,
|
|
8
|
-
transforms,
|
|
9
|
-
} from './client.js';
|
|
10
|
-
|
|
11
|
-
// Re-export types
|
|
12
|
-
export type {
|
|
13
|
-
TriliumNote,
|
|
14
|
-
TriliumBranch,
|
|
15
|
-
TriliumAttribute,
|
|
16
|
-
TriliumAttachment,
|
|
17
|
-
TriliumAppInfo,
|
|
18
|
-
TriliumClientConfig,
|
|
19
|
-
paths,
|
|
20
|
-
components,
|
|
21
|
-
// Mapper types
|
|
22
|
-
MappingConfig,
|
|
23
|
-
FieldMapping,
|
|
24
|
-
TransformFunction,
|
|
25
|
-
ComputedFunction,
|
|
26
|
-
TriliumSearchHelpers,
|
|
27
|
-
TriliumSearchConditions,
|
|
28
|
-
TriliumSearchLogical,
|
|
29
|
-
ComparisonOperator,
|
|
30
|
-
ConditionValue,
|
|
31
|
-
SearchValue,
|
|
32
|
-
} from './client.js';
|
|
33
|
-
|
|
34
|
-
// Re-export generated types for advanced usage
|
|
1
|
+
// Main exports for the Trilium API client
|
|
2
|
+
export {
|
|
3
|
+
createTriliumClient,
|
|
4
|
+
default as createClient,
|
|
5
|
+
// Mapper utilities
|
|
6
|
+
TriliumMapper,
|
|
7
|
+
buildSearchQuery,
|
|
8
|
+
transforms,
|
|
9
|
+
} from './client.js';
|
|
10
|
+
|
|
11
|
+
// Re-export types
|
|
12
|
+
export type {
|
|
13
|
+
TriliumNote,
|
|
14
|
+
TriliumBranch,
|
|
15
|
+
TriliumAttribute,
|
|
16
|
+
TriliumAttachment,
|
|
17
|
+
TriliumAppInfo,
|
|
18
|
+
TriliumClientConfig,
|
|
19
|
+
paths,
|
|
20
|
+
components,
|
|
21
|
+
// Mapper types
|
|
22
|
+
MappingConfig,
|
|
23
|
+
FieldMapping,
|
|
24
|
+
TransformFunction,
|
|
25
|
+
ComputedFunction,
|
|
26
|
+
TriliumSearchHelpers,
|
|
27
|
+
TriliumSearchConditions,
|
|
28
|
+
TriliumSearchLogical,
|
|
29
|
+
ComparisonOperator,
|
|
30
|
+
ConditionValue,
|
|
31
|
+
SearchValue,
|
|
32
|
+
} from './client.js';
|
|
33
|
+
|
|
34
|
+
// Re-export generated types for advanced usage
|
|
35
35
|
export type { operations } from './generated/trilium.js';
|