-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
96 lines (92 loc) · 3.01 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import Realm from 'realm'
declare class ClipyMate {
realm: Realm
opt: ClipyMate.DefaultClipyMateOpt
models: {
CPYClip: Realm.Results<ClipyMate.clip>,
CPYFolder: Realm.Results<ClipyMate.folder>,
CPYSnippet: Realm.Results<ClipyMate.snippet>,
}
// getters
public readonly CPYClip: Realm.Results<ClipyMate.clip>
public readonly CPYFolder: Realm.Results<ClipyMate.folder>
public readonly CPYSnippet: Realm.Results<ClipyMate.snippet>
constructor(opt?: ClipyMate.ClipyMateOpt)
init(): Promise<void>
disconnect(): void
readSchemas(keys?: ClipyMate.WatchBoard[]): Promise<{
schemaVersion: number,
CPYClip?: {},
CPYFolder?: {},
CPYSnippet?: {},
}>
readSnippets(orderByIndex?: boolean): Promise<ClipyMate.folder[]>
getFolder(folderId: string): Promise<ClipyMate.folder>
getSnippet(snippetId: string): Promise<ClipyMate.snippet>
upsertFolder(opt: ClipyMate.upsertFolderOpt): Promise<ClipyMate.folder>
upsertSnippet(opt: ClipyMate.upsertSnippetOpt, folderId?: string): Promise<ClipyMate.snippet>
destroyFolder(folderId: string, orderByIndex?: boolean): Promise<ClipyMate.folder>
destroySnippet(snippetId: string): Promise<ClipyMate.snippet>
clearAllSnippets(): Promise<void>
private destroy(obj: Realm.Object): Promise<void>
buildXml(orderByIndex?: boolean, detailMode?: boolean): Promise<string>
parseXml(xmlString: string): Promise<ClipyMate.folder[]>
addListener(
boardName: ClipyMate.WatchBoard,
callbacks: ClipyMate.RealmListener | ClipyMate.RealmListenerSet,
rawCollection?: boolean
): Promise<void>
removeAllListeners(boardName?: ClipyMate.WatchBoard): void
}
declare namespace ClipyMate {
type WatchBoard = 'CPYClip' | 'CPYFolder' | 'CPYSnippet'
type RealmEventName = 'insertions' | 'modifications' | 'deletions'
type RealmListener = (results: RealmEventObjects) => void | Promise<void>
interface RealmListenerSet {
insertions?: RealmListener,
modifications?: RealmListener,
deletions?: RealmListener,
}
interface RealmEventObjects {
changes: Realm.CollectionChangeSet,
eventNames: RealmEventName[],
collection?: Realm.Collection<Realm.Object>,
targets?: RealmEventTargets,
}
interface RealmEventTargets {
insertions?: Realm.Object,
modifications?: Realm.Object,
}
type DefaultClipyMateOpt = {
realmPath: string,
watchBoards: WatchBoard[],
events: RealmEventName[],
}
type ClipyMateOpt = Partial<DefaultClipyMateOpt>
interface clip {
title: string,
dataPath?: string,
dataHash?: string,
primaryType?: string, // Only NSStringPboardType?
updateTime?: number,
thumbnailPath?: string,
isColorCode?: boolean,
}
type folder = {
title: string,
snippets: snippet[] | upsertSnippetOpt[],
index: number,
identifier: string,
enable: boolean,
}
type upsertFolderOpt = Partial<folder>
type snippet = {
title: string,
content: string,
index: number,
identifier: string,
enable: boolean,
}
type upsertSnippetOpt = Partial<snippet>
}
export = ClipyMate