synapse-db 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +46 -2
- package/dist/canvasExporter.d.ts +32 -0
- package/dist/collection.d.ts +52 -0
- package/dist/connectome.d.ts +85 -0
- package/dist/engine.d.ts +59 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +942 -0
- package/dist/migrator.d.ts +24 -0
- package/dist/serializer.d.ts +25 -0
- package/dist/types.d.ts +62 -0
- package/package.json +42 -4
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SynapseEngine } from "./engine";
|
|
2
|
+
import type { SynapseDocumentInput } from "./types";
|
|
3
|
+
export interface SqliteMigrationMapping<TRow = any, TData = any> {
|
|
4
|
+
readonly tableName: string;
|
|
5
|
+
readonly targetCollection: string;
|
|
6
|
+
readonly mapRow: (row: TRow) => {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly data: TData;
|
|
9
|
+
readonly body?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare class SynapseMigrator {
|
|
13
|
+
private readonly engine;
|
|
14
|
+
constructor(engine: SynapseEngine);
|
|
15
|
+
/**
|
|
16
|
+
* SQLite 데이터베이스의 테이블을 읽어 마크다운 컬렉션으로 일괄 마이그레이션
|
|
17
|
+
* (SQL Injection 방어를 위한 테이블 식별자 화이트리스트 정규식 검증 포함)
|
|
18
|
+
*/
|
|
19
|
+
migrateFromSqlite<TRow = any, TData = any>(sqliteDbPath: string, mappings: readonly SqliteMigrationMapping<TRow, TData>[]): Promise<Record<string, number>>;
|
|
20
|
+
/**
|
|
21
|
+
* JSON 배열 데이터를 마크다운 컬렉션으로 마이그레이션
|
|
22
|
+
*/
|
|
23
|
+
migrateFromJsonArray<TItem = any, TData = any>(targetCollection: string, items: readonly TItem[], mapItem: (item: TItem) => SynapseDocumentInput<TData>): Promise<number>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SynapseWikilink } from "./types";
|
|
2
|
+
/** 파싱된 마크다운 원시 구조 */
|
|
3
|
+
export interface RawParsedMarkdown<T = Record<string, any>> {
|
|
4
|
+
readonly frontmatter: T;
|
|
5
|
+
readonly body: string;
|
|
6
|
+
readonly wikilinks: readonly SynapseWikilink[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 텍스트에서 옵시디언 위키링크([[target|alias]] 또는 [[target]]) 자동 추출
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractWikilinks(text: string, defaultCollection?: string): SynapseWikilink[];
|
|
12
|
+
/**
|
|
13
|
+
* YAML Frontmatter 안전 파서 (순수 TypeScript 무손실 복원)
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseMarkdownFile<T = Record<string, any>>(rawContent: string, defaultCollection?: string): RawParsedMarkdown<T>;
|
|
16
|
+
/** YAML 단일 스칼라 및 인라인 JSON 값 무손실 파싱 */
|
|
17
|
+
export declare function parseYamlScalar(val: string): any;
|
|
18
|
+
/**
|
|
19
|
+
* 범용 문서를 마크다운 파일 내용으로 직렬화
|
|
20
|
+
*/
|
|
21
|
+
export declare function stringifyDocument(data: Record<string, any>, body?: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* 원자적 디스크 쓰기 (임시 파일 후 atomic rename)
|
|
24
|
+
*/
|
|
25
|
+
export declare function atomicWriteFile(targetPath: string, content: string): void;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 범용 마크다운 시냅스 데이터베이스 타입 규격 (Synapse-DB Type Specifications)
|
|
3
|
+
* SOLID 원칙 준수: 단일 책임 원칙(SRP)에 따른 타입 정의 분리
|
|
4
|
+
*/
|
|
5
|
+
/** 시냅스 위키링크 규격 ([[collection/id|alias]]) */
|
|
6
|
+
export interface SynapseWikilink {
|
|
7
|
+
readonly raw: string;
|
|
8
|
+
readonly targetCollection: string;
|
|
9
|
+
readonly targetId: string;
|
|
10
|
+
readonly alias?: string;
|
|
11
|
+
}
|
|
12
|
+
/** 범용 시냅스 간선 (Synaptic Edge) */
|
|
13
|
+
export interface SynapticEdge {
|
|
14
|
+
readonly fromNodeId: string;
|
|
15
|
+
readonly toNodeId: string;
|
|
16
|
+
readonly relation?: string;
|
|
17
|
+
readonly alias?: string;
|
|
18
|
+
}
|
|
19
|
+
/** 마크다운 볼트에 저장되는 범용 문서 (Synapse Document) */
|
|
20
|
+
export interface SynapseDocument<TData = Record<string, any>> {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly collection: string;
|
|
23
|
+
readonly data: TData;
|
|
24
|
+
readonly body: string;
|
|
25
|
+
readonly createdAt: string;
|
|
26
|
+
readonly updatedAt: string;
|
|
27
|
+
readonly wikilinks: readonly SynapseWikilink[];
|
|
28
|
+
}
|
|
29
|
+
/** 문서 생성 및 저장 입력 규격 */
|
|
30
|
+
export interface SynapseDocumentInput<TData = Record<string, any>> {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly data: TData;
|
|
33
|
+
readonly body?: string;
|
|
34
|
+
readonly createdAt?: string;
|
|
35
|
+
readonly updatedAt?: string;
|
|
36
|
+
}
|
|
37
|
+
/** 쿼리 및 필터링 옵션 */
|
|
38
|
+
export interface SynapseQueryOptions<TData = Record<string, any>> {
|
|
39
|
+
readonly filter?: (doc: SynapseDocument<TData>) => boolean;
|
|
40
|
+
readonly sortBy?: (a: SynapseDocument<TData>, b: SynapseDocument<TData>) => number;
|
|
41
|
+
readonly limit?: number;
|
|
42
|
+
readonly offset?: number;
|
|
43
|
+
}
|
|
44
|
+
/** 전문 검색(Full-text Search) 결과 */
|
|
45
|
+
export interface SynapseSearchResult<TData = Record<string, any>> {
|
|
46
|
+
readonly document: SynapseDocument<TData>;
|
|
47
|
+
readonly score: number;
|
|
48
|
+
readonly matchedTerms: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
/** 데이터베이스 환경 설정 */
|
|
51
|
+
export interface SynapseDBConfig {
|
|
52
|
+
readonly vaultDir: string;
|
|
53
|
+
readonly autoWatch?: boolean;
|
|
54
|
+
readonly persistDebounceMs?: number;
|
|
55
|
+
}
|
|
56
|
+
/** 시냅스 데이터베이스 전체 통계 요약 */
|
|
57
|
+
export interface SynapseDBStats {
|
|
58
|
+
readonly collectionsCount: number;
|
|
59
|
+
readonly totalDocuments: number;
|
|
60
|
+
readonly totalSynapses: number;
|
|
61
|
+
readonly collectionBreakdown: Record<string, number>;
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "synapse-db",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Universal Markdown-First & In-Memory Connectome Database with Wikilink Auto-Wiring, Korean N-gram BM25 & Obsidian Canvas Exporter",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "bun build index.ts --outfile dist/index.js --target bun && tsc -p tsconfig.build.json",
|
|
18
|
+
"prepublishOnly": "bun run build",
|
|
19
|
+
"test": "bun test"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/minseokk77/synapse-kit.git",
|
|
24
|
+
"directory": "db"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"markdown-db",
|
|
28
|
+
"obsidian",
|
|
29
|
+
"connectome",
|
|
30
|
+
"wikilinks",
|
|
31
|
+
"knowledge-graph",
|
|
32
|
+
"bm25",
|
|
33
|
+
"ai-native",
|
|
34
|
+
"synapse-kit",
|
|
35
|
+
"bun"
|
|
36
|
+
],
|
|
37
|
+
"author": "Vesper",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"dependencies": {},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.8.7",
|
|
42
|
+
"typescript": "^5.6.3"
|
|
43
|
+
}
|
|
44
|
+
}
|