obsidian-dev-utils 16.3.0 → 16.4.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/CHANGELOG.md +7 -0
- package/README.md +21 -2
- package/dist/bin/cli.cjs +1 -1
- package/dist/dprint.json +22 -0
- package/dist/lib/@types/debug.d.ts +1 -1
- package/dist/lib/Async.cjs +10 -5
- package/dist/lib/Debug.cjs +4 -2
- package/dist/lib/Library.cjs +1 -1
- package/dist/lib/Object.cjs +1 -1
- package/dist/lib/Object.d.ts +1 -1
- package/dist/lib/Path.cjs +1 -1
- package/dist/lib/Path.d.ts +5 -5
- package/dist/lib/obsidian/@types/Dataview/api/data-array.d.ts +116 -114
- package/dist/lib/obsidian/@types/Dataview/api/extensions.d.ts +8 -8
- package/dist/lib/obsidian/@types/Dataview/api/inline-api.d.ts +172 -151
- package/dist/lib/obsidian/@types/Dataview/api/plugin-api.d.ts +183 -166
- package/dist/lib/obsidian/@types/Dataview/api/result.d.ts +28 -28
- package/dist/lib/obsidian/@types/Dataview/data-import/csv.d.ts +1 -1
- package/dist/lib/obsidian/@types/Dataview/data-import/inline-field.d.ts +15 -15
- package/dist/lib/obsidian/@types/Dataview/data-import/markdown-file.d.ts +23 -7
- package/dist/lib/obsidian/@types/Dataview/data-import/persister.d.ts +25 -25
- package/dist/lib/obsidian/@types/Dataview/data-import/web-worker/import-impl.d.ts +5 -2
- package/dist/lib/obsidian/@types/Dataview/data-import/web-worker/import-manager.d.ts +30 -25
- package/dist/lib/obsidian/@types/Dataview/data-index/index.d.ts +156 -149
- package/dist/lib/obsidian/@types/Dataview/data-index/resolver.d.ts +9 -6
- package/dist/lib/obsidian/@types/Dataview/data-index/source.d.ts +43 -43
- package/dist/lib/obsidian/@types/Dataview/data-model/markdown.d.ts +105 -99
- package/dist/lib/obsidian/@types/Dataview/data-model/serialized/markdown.d.ts +92 -89
- package/dist/lib/obsidian/@types/Dataview/data-model/transferable.d.ts +4 -4
- package/dist/lib/obsidian/@types/Dataview/data-model/value.d.ts +139 -112
- package/dist/lib/obsidian/@types/Dataview/expression/binaryop.d.ts +31 -17
- package/dist/lib/obsidian/@types/Dataview/expression/context.d.ts +39 -33
- package/dist/lib/obsidian/@types/Dataview/expression/field.d.ts +46 -46
- package/dist/lib/obsidian/@types/Dataview/expression/functions.d.ts +120 -108
- package/dist/lib/obsidian/@types/Dataview/expression/parse.d.ts +135 -115
- package/dist/lib/obsidian/@types/Dataview/index.d.ts +48 -14
- package/dist/lib/obsidian/@types/Dataview/main.d.ts +50 -42
- package/dist/lib/obsidian/@types/Dataview/query/engine.d.ts +60 -44
- package/dist/lib/obsidian/@types/Dataview/query/parse.d.ts +31 -18
- package/dist/lib/obsidian/@types/Dataview/query/query.d.ts +45 -45
- package/dist/lib/obsidian/@types/Dataview/settings.d.ts +50 -50
- package/dist/lib/obsidian/@types/Dataview/typings/obsidian-ex.d.ts +16 -16
- package/dist/lib/obsidian/@types/Dataview/typings/workers.d.ts +3 -3
- package/dist/lib/obsidian/@types/Dataview/ui/export/markdown.d.ts +9 -3
- package/dist/lib/obsidian/@types/Dataview/ui/lp-render.d.ts +34 -21
- package/dist/lib/obsidian/@types/Dataview/ui/markdown.d.ts +49 -36
- package/dist/lib/obsidian/@types/Dataview/ui/refreshable-view.d.ts +15 -12
- package/dist/lib/obsidian/@types/Dataview/ui/render.d.ts +27 -6
- package/dist/lib/obsidian/@types/Dataview/ui/views/calendar-view.d.ts +15 -15
- package/dist/lib/obsidian/@types/Dataview/ui/views/inline-field-live-preview.d.ts +30 -17
- package/dist/lib/obsidian/@types/Dataview/ui/views/inline-view.d.ts +25 -16
- package/dist/lib/obsidian/@types/Dataview/ui/views/js-view.d.ts +18 -18
- package/dist/lib/obsidian/@types/Dataview/ui/views/list-view.d.ts +14 -14
- package/dist/lib/obsidian/@types/Dataview/ui/views/table-view.d.ts +17 -17
- package/dist/lib/obsidian/@types/Dataview/ui/views/task-view.d.ts +26 -14
- package/dist/lib/obsidian/@types/Dataview/util/media.d.ts +1 -1
- package/dist/lib/obsidian/@types/Dataview/util/normalize.d.ts +6 -3
- package/dist/lib/obsidian/App.cjs +1 -1
- package/dist/lib/obsidian/AttachmentPath.cjs +1 -1
- package/dist/lib/obsidian/Dataview.cjs +26 -17
- package/dist/lib/obsidian/FileChange.cjs +1 -1
- package/dist/lib/obsidian/FileChange.d.ts +4 -4
- package/dist/lib/obsidian/FileManager.cjs +2 -2
- package/dist/lib/obsidian/Link.cjs +1 -1
- package/dist/lib/obsidian/Link.d.ts +4 -4
- package/dist/lib/obsidian/Markdown.cjs +17 -1
- package/dist/lib/obsidian/Markdown.d.ts +11 -1
- package/dist/lib/obsidian/MarkdownCodeBlockProcessor.cjs +1 -1
- package/dist/lib/obsidian/MetadataCache.cjs +7 -3
- package/dist/lib/obsidian/Plugin/PluginSettingsTabBase.cjs +1 -1
- package/dist/lib/obsidian/Reference.cjs +1 -1
- package/dist/lib/obsidian/Reference.d.ts +6 -6
- package/dist/lib/obsidian/RenameDeleteHandler.cjs +7 -3
- package/dist/lib/obsidian/RenameDeleteHandler.d.ts +2 -2
- package/dist/lib/obsidian/Vault.cjs +1 -1
- package/dist/lib/obsidian/VaultEx.cjs +1 -1
- package/dist/lib/scripts/ESLint/ESLint.cjs +4 -2
- package/dist/lib/scripts/ESLint/eslint.config.cjs +5 -2
- package/dist/lib/scripts/Fs.cjs +1 -1
- package/dist/lib/scripts/JSON.cjs +1 -1
- package/dist/lib/scripts/Npm.cjs +1 -1
- package/dist/lib/scripts/ObsidianDevUtilsRepoPaths.cjs +2 -1
- package/dist/lib/scripts/ObsidianDevUtilsRepoPaths.d.ts +2 -0
- package/dist/lib/scripts/cli.cjs +23 -18
- package/dist/lib/scripts/esbuild/ObsidianPluginBuilder.cjs +5 -3
- package/dist/lib/scripts/esbuild/fixSourceMapsPlugin.cjs +1 -1
- package/dist/lib/scripts/esbuild/preprocessPlugin.cjs +1 -1
- package/dist/lib/scripts/format.cjs +56 -0
- package/dist/lib/scripts/format.d.ts +10 -0
- package/dist/lib/scripts/index.cjs +4 -1
- package/dist/lib/scripts/index.d.ts +1 -0
- package/dist/lib/scripts/version.cjs +18 -6
- package/package.json +13 -10
- package/dist/obsidian-dev-utils-16.3.0.tgz +0 -0
@@ -1,32 +1,37 @@
|
|
1
1
|
/** Controls and creates Dataview file importers, allowing for asynchronous loading and parsing of files. */
|
2
|
-
import type {
|
2
|
+
import type {
|
3
|
+
Component,
|
4
|
+
MetadataCache,
|
5
|
+
TFile,
|
6
|
+
Vault
|
7
|
+
} from 'obsidian';
|
3
8
|
/** Callback when a file is resolved. */
|
4
9
|
type FileCallback = (p: any) => void;
|
5
10
|
/** Multi-threaded file parser which debounces rapid file requests automatically. */
|
6
11
|
export declare class FileImporter extends Component {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
12
|
+
numWorkers: number;
|
13
|
+
vault: Vault;
|
14
|
+
metadataCache: MetadataCache;
|
15
|
+
workers: Worker[];
|
16
|
+
/** Tracks which workers are actively parsing a file, to make sure we properly delegate results. */
|
17
|
+
busy: boolean[];
|
18
|
+
/** List of files which have been queued for a reload. */
|
19
|
+
reloadQueue: TFile[];
|
20
|
+
/** Fast-access set which holds the list of files queued to be reloaded; used for debouncing. */
|
21
|
+
reloadSet: Set<string>;
|
22
|
+
/** Paths -> promises for file reloads which have not yet been queued. */
|
23
|
+
callbacks: Map<string, [FileCallback, FileCallback][]>;
|
24
|
+
constructor(numWorkers: number, vault: Vault, metadataCache: MetadataCache);
|
25
|
+
/**
|
26
|
+
* Queue the given file for reloading. Multiple reload requests for the same file in a short time period will be de-bounced
|
27
|
+
* and all be resolved by a single actual file reload.
|
28
|
+
*/
|
29
|
+
reload<T>(file: TFile): Promise<T>;
|
30
|
+
/** Finish the parsing of a file, potentially queueing a new file. */
|
31
|
+
private finish;
|
32
|
+
/** Send a new task to the given worker ID. */
|
33
|
+
private send;
|
34
|
+
/** Find the next available, non-busy worker; return undefined if all workers are busy. */
|
35
|
+
private nextAvailableWorker;
|
31
36
|
}
|
32
37
|
export {};
|
@@ -1,179 +1,186 @@
|
|
1
1
|
/** Stores various indices on all files in the vault to make dataview generation fast. */
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
import type { DateTime } from 'luxon';
|
3
|
+
import type {
|
4
|
+
App,
|
5
|
+
Component,
|
6
|
+
MetadataCache,
|
7
|
+
TAbstractFile,
|
8
|
+
TFile,
|
9
|
+
Vault
|
10
|
+
} from 'obsidian';
|
11
|
+
import type { Result } from '../api/result.d.ts';
|
12
|
+
import type { LocalStorageCache } from '../data-import/persister.d.ts';
|
13
|
+
import type { FileImporter } from '../data-import/web-worker/import-manager.d.ts';
|
14
|
+
import type { PageMetadata } from '../data-model/markdown.d.ts';
|
15
|
+
import type { DataObject } from '../data-model/value.d.ts';
|
9
16
|
/** Aggregate index which has several sub-indices and will initialize all of them. */
|
10
17
|
export declare class FullIndex extends Component {
|
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
|
-
|
18
|
+
app: App;
|
19
|
+
indexVersion: string;
|
20
|
+
onChange: () => void;
|
21
|
+
/** Generate a full index from the given vault. */
|
22
|
+
static create(app: App, indexVersion: string, onChange: () => void): FullIndex;
|
23
|
+
/** Whether all files in the vault have been indexed at least once. */
|
24
|
+
initialized: boolean;
|
25
|
+
/** I/O access to the Obsidian vault contents. */
|
26
|
+
vault: Vault;
|
27
|
+
/** Access to in-memory metadata, useful for parsing and metadata lookups. */
|
28
|
+
metadataCache: MetadataCache;
|
29
|
+
/** Persistent IndexedDB backing store, used for faster startup. */
|
30
|
+
persister: LocalStorageCache;
|
31
|
+
pages: Map<string, PageMetadata>;
|
32
|
+
/** Map files -> tags in that file, and tags -> files. This version includes subtags. */
|
33
|
+
tags: ValueCaseInsensitiveIndexMap;
|
34
|
+
/** Map files -> exact tags in that file, and tags -> files. This version does not automatically add subtags. */
|
35
|
+
etags: ValueCaseInsensitiveIndexMap;
|
36
|
+
/** Map files -> linked files in that file, and linked file -> files that link to it. */
|
37
|
+
links: IndexMap;
|
38
|
+
/** Search files by path prefix. */
|
39
|
+
prefix: PrefixIndex;
|
40
|
+
/** Allows for efficient lookups of whether a file is starred or not. */
|
41
|
+
starred: StarredCache;
|
42
|
+
/** Caches data in CSV files. */
|
43
|
+
csv: CsvCache;
|
44
|
+
/**
|
45
|
+
* The current "revision" of the index, which monotonically increases for every index change. Use this to determine
|
46
|
+
* if you are up to date.
|
47
|
+
*/
|
48
|
+
revision: number;
|
49
|
+
/** Asynchronously parses files in the background using web workers. */
|
50
|
+
importer: FileImporter;
|
51
|
+
/** Construct a new index using the app data and a current data version. */
|
52
|
+
private constructor();
|
53
|
+
/** Trigger a metadata event on the metadata cache. */
|
54
|
+
private trigger;
|
55
|
+
/** "Touch" the index, incrementing the revision number and causing downstream views to reload. */
|
56
|
+
touch(): void;
|
57
|
+
/** Runs through the whole vault to set up initial file metadata. */
|
58
|
+
initialize(): void;
|
59
|
+
/** Drops the local storage cache and re-indexes all files; this should generally be used if you expect cache issues. */
|
60
|
+
reinitialize(): Promise<void>;
|
61
|
+
/** Internal asynchronous initializer. */
|
62
|
+
private _initialize;
|
63
|
+
rename(file: TAbstractFile, oldPath: string): void;
|
64
|
+
/** Queue a file for reloading; this is done asynchronously in the background and may take a few seconds. */
|
65
|
+
reload(file: TFile): Promise<{
|
66
|
+
cached: boolean;
|
67
|
+
skipped: boolean;
|
68
|
+
}>;
|
69
|
+
/** Import a file directly from disk, skipping the cache. */
|
70
|
+
private import;
|
71
|
+
/** Finish the reloading of file metadata by adding it to in memory indexes. */
|
72
|
+
private finish;
|
66
73
|
}
|
67
74
|
/** Indexes files by their full prefix - essentially a simple prefix tree. */
|
68
75
|
export declare class PrefixIndex extends Component {
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
76
|
+
vault: Vault;
|
77
|
+
updateRevision: () => void;
|
78
|
+
static create(vault: Vault, updateRevision: () => void): PrefixIndex;
|
79
|
+
constructor(vault: Vault, updateRevision: () => void);
|
80
|
+
private walk;
|
81
|
+
/** Get the list of all files under the given path. */
|
82
|
+
get(prefix: string, filter?: (path: string) => boolean): Set<string>;
|
83
|
+
/** Determines if the given path exists in the prefix index. */
|
84
|
+
pathExists(path: string): boolean;
|
85
|
+
/** Determines if the given prefix exists in the prefix index. */
|
86
|
+
nodeExists(prefix: string): boolean;
|
87
|
+
/**
|
88
|
+
* Use the in-memory prefix index to convert a relative path to an absolute one.
|
89
|
+
*/
|
90
|
+
resolveRelative(path: string, origin?: string): string;
|
84
91
|
}
|
85
92
|
/** Simple path filters which filter file types. */
|
86
93
|
export declare namespace PathFilters {
|
87
|
-
|
88
|
-
|
94
|
+
function csv(path: string): boolean;
|
95
|
+
function markdown(path: string): boolean;
|
89
96
|
}
|
90
97
|
/**
|
91
98
|
* Caches in-use CSVs to make high-frequency reloads (such as actively looking at a document
|
92
99
|
* that uses CSV) fast.
|
93
100
|
*/
|
94
101
|
export declare class CsvCache extends Component {
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
102
|
+
vault: Vault;
|
103
|
+
static CACHE_EXPIRY_SECONDS: number;
|
104
|
+
cache: Map<string, {
|
105
|
+
data: DataObject[];
|
106
|
+
loadTime: DateTime;
|
107
|
+
}>;
|
108
|
+
cacheClearInterval: number;
|
109
|
+
constructor(vault: Vault);
|
110
|
+
/** Load a CSV file from the cache, doing a fresh load if it has not been loaded. */
|
111
|
+
get(path: string): Promise<Result<DataObject[], string>>;
|
112
|
+
/** Do the actual raw loading of a CSV path (which is either local or an HTTP request). */
|
113
|
+
private loadInternal;
|
114
|
+
/** Clear old entries in the cache (as measured by insertion time). */
|
115
|
+
private clearOldEntries;
|
109
116
|
}
|
110
117
|
export type StarredEntry = {
|
111
|
-
|
112
|
-
|
113
|
-
|
118
|
+
type: 'group';
|
119
|
+
items: StarredEntry[];
|
120
|
+
title: string;
|
114
121
|
} | {
|
115
|
-
|
116
|
-
|
117
|
-
|
122
|
+
type: 'file';
|
123
|
+
path: string;
|
124
|
+
title: string;
|
118
125
|
} | {
|
119
|
-
|
126
|
+
type: 'folder';
|
120
127
|
} | {
|
121
|
-
|
128
|
+
type: 'query';
|
122
129
|
};
|
123
130
|
/** Optional connector to the Obsidian 'Starred' plugin which allows for efficiently querying if a file is starred or not. */
|
124
131
|
export declare class StarredCache extends Component {
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
132
|
+
app: App;
|
133
|
+
onUpdate: () => void;
|
134
|
+
/** Initial delay before checking the cache; we need to wait for it to asynchronously load the initial stars. */
|
135
|
+
static INITIAL_DELAY: number;
|
136
|
+
/** How frequently to check for star updates. */
|
137
|
+
static REFRESH_INTERVAL: number;
|
138
|
+
/** Set of all starred file paths. */
|
139
|
+
private stars;
|
140
|
+
constructor(app: App, onUpdate: () => void);
|
141
|
+
/** Determines if the given path is starred. */
|
142
|
+
starred(path: string): boolean;
|
143
|
+
private reload;
|
144
|
+
/** Fetch all starred files from the stars plugin, if present. */
|
145
|
+
private static fetch;
|
139
146
|
}
|
140
147
|
/** A generic index which indexes variables of the form key -> value[], allowing both forward and reverse lookups. */
|
141
148
|
export declare class IndexMap {
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
149
|
+
/** Maps key -> values for that key. */
|
150
|
+
map: Map<string, Set<string>>;
|
151
|
+
/** Cached inverse map; maps value -> keys that reference that value. */
|
152
|
+
invMap: Map<string, Set<string>>;
|
153
|
+
/** Create a new, empty index map. */
|
154
|
+
constructor();
|
155
|
+
/** Returns all values for the given key. */
|
156
|
+
get(key: string): Set<string>;
|
157
|
+
/** Returns all keys that reference the given key. Mutating the returned set is not allowed. */
|
158
|
+
getInverse(value: string): Readonly<Set<string>>;
|
159
|
+
/** Sets the key to the given values; this will delete the old mapping for the key if one was present. */
|
160
|
+
set(key: string, values: Set<string>): this;
|
161
|
+
/** Clears all values for the given key so they can be re-added. */
|
162
|
+
delete(key: string): boolean;
|
163
|
+
/** Rename all references to the given key to a new value. */
|
164
|
+
rename(oldKey: string, newKey: string): boolean;
|
165
|
+
/** Clear the entire index. */
|
166
|
+
clear(): void;
|
167
|
+
static EMPTY_SET: Readonly<Set<string>>;
|
161
168
|
}
|
162
169
|
/** Index map wrapper which is case-insensitive in the key. */
|
163
170
|
export declare class ValueCaseInsensitiveIndexMap {
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
171
|
+
delegate: IndexMap;
|
172
|
+
/** Create a new, empty case insensitive index map. */
|
173
|
+
constructor(delegate?: IndexMap);
|
174
|
+
/** Returns all values for the given key. */
|
175
|
+
get(key: string): Set<string>;
|
176
|
+
/** Returns all keys that reference the given value. Mutating the returned set is not allowed. */
|
177
|
+
getInverse(value: string): Readonly<Set<string>>;
|
178
|
+
/** Sets the key to the given values; this will delete the old mapping for the key if one was present. */
|
179
|
+
set(key: string, values: Set<string>): this;
|
180
|
+
/** Clears all values for the given key so they can be re-added. */
|
181
|
+
delete(key: string): boolean;
|
182
|
+
/** Rename all references to the given key to a new value. */
|
183
|
+
rename(oldKey: string, newKey: string): boolean;
|
184
|
+
/** Clear the entire index. */
|
185
|
+
clear(): void;
|
179
186
|
}
|
@@ -1,12 +1,15 @@
|
|
1
1
|
/** Collect data matching a source query. */
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
|
2
|
+
import type { Result } from '../api/result.d.ts';
|
3
|
+
import type { FullIndex } from '../data-index/index.d.ts';
|
4
|
+
import type {
|
5
|
+
DataObject,
|
6
|
+
Literal
|
7
|
+
} from '../data-model/value.d.ts';
|
8
|
+
import type { Source } from './source.d.ts';
|
6
9
|
/** A data row which has an ID and associated data (like page link / page data). */
|
7
10
|
export type Datarow<T> = {
|
8
|
-
|
9
|
-
|
11
|
+
id: Literal;
|
12
|
+
data: T;
|
10
13
|
};
|
11
14
|
/** Find source paths which match the given source. */
|
12
15
|
export declare function matchingSourcePaths(source: Source, index: FullIndex, originFile?: string): Result<Set<string>, string>;
|
@@ -2,70 +2,70 @@
|
|
2
2
|
/** The source of files for a query. */
|
3
3
|
export type Source = TagSource | CsvSource | FolderSource | LinkSource | EmptySource | NegatedSource | BinaryOpSource;
|
4
4
|
/** Valid operations for combining sources. */
|
5
|
-
export type SourceOp =
|
5
|
+
export type SourceOp = '&' | '|';
|
6
6
|
/** A tag as a source of data. */
|
7
7
|
export interface TagSource {
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
type: 'tag';
|
9
|
+
/** The tag to source from. */
|
10
|
+
tag: string;
|
11
11
|
}
|
12
12
|
/** A csv as a source of data. */
|
13
13
|
export interface CsvSource {
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
type: 'csv';
|
15
|
+
/** The path to the CSV file. */
|
16
|
+
path: string;
|
17
17
|
}
|
18
18
|
/** A folder prefix as a source of data. */
|
19
19
|
export interface FolderSource {
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
type: 'folder';
|
21
|
+
/** The folder prefix to source from. */
|
22
|
+
folder: string;
|
23
23
|
}
|
24
24
|
/** Either incoming or outgoing links to a given file. */
|
25
25
|
export interface LinkSource {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
type: 'link';
|
27
|
+
/** The file to look for links to/from. */
|
28
|
+
file: string;
|
29
|
+
/**
|
30
|
+
* The direction to look - if incoming, then all files linking to the target file. If outgoing, then all files
|
31
|
+
* which the file links to.
|
32
|
+
*/
|
33
|
+
direction: 'incoming' | 'outgoing';
|
34
34
|
}
|
35
35
|
/** A source which is everything EXCEPT the files returned by the given source. */
|
36
36
|
export interface NegatedSource {
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
type: 'negate';
|
38
|
+
/** The source to negate. */
|
39
|
+
child: Source;
|
40
40
|
}
|
41
41
|
/** A source which yields nothing. */
|
42
42
|
export interface EmptySource {
|
43
|
-
|
43
|
+
type: 'empty';
|
44
44
|
}
|
45
45
|
/** A source made by combining subsources with a logical operators. */
|
46
46
|
export interface BinaryOpSource {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
type: 'binaryop';
|
48
|
+
op: SourceOp;
|
49
|
+
left: Source;
|
50
|
+
right: Source;
|
51
51
|
}
|
52
52
|
/** Utility functions for creating and manipulating sources. */
|
53
53
|
export declare namespace Sources {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
54
|
+
/** Create a source which searches from a tag. */
|
55
|
+
function tag(tag: string): TagSource;
|
56
|
+
/** Create a source which fetches from a CSV file. */
|
57
|
+
function csv(path: string): CsvSource;
|
58
|
+
/** Create a source which searches for files under a folder prefix. */
|
59
|
+
function folder(prefix: string): FolderSource;
|
60
|
+
/** Create a source which searches for files which link to/from a given file. */
|
61
|
+
function link(file: string, incoming: boolean): LinkSource;
|
62
|
+
/** Create a source which joins two sources by a logical operator (and/or). */
|
63
|
+
function binaryOp(left: Source, op: SourceOp, right: Source): Source;
|
64
|
+
/** Create a source which takes the intersection of two sources. */
|
65
|
+
function and(left: Source, right: Source): Source;
|
66
|
+
/** Create a source which takes the union of two sources. */
|
67
|
+
function or(left: Source, right: Source): Source;
|
68
|
+
/** Create a source which negates the underlying source. */
|
69
|
+
function negate(child: Source): NegatedSource;
|
70
|
+
function empty(): EmptySource;
|
71
71
|
}
|