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,192 +1,209 @@
|
|
1
1
|
/** The general, externally accessible plugin API (available at `app.plugins.plugins.dataview.api` or as global `DataviewAPI`). */
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
import
|
8
|
-
import type {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
import type {
|
14
|
-
import type {
|
15
|
-
import type {
|
2
|
+
import type { CompareOperator } from 'compare-versions';
|
3
|
+
import type {
|
4
|
+
DateTime,
|
5
|
+
Duration
|
6
|
+
} from 'luxon';
|
7
|
+
import * as Luxon from 'luxon';
|
8
|
+
import type {
|
9
|
+
App,
|
10
|
+
Component,
|
11
|
+
MarkdownPostProcessorContext
|
12
|
+
} from 'obsidian';
|
13
|
+
import type { Result } from '../api/result.d.ts';
|
14
|
+
import type { FullIndex } from '../data-index/index.d.ts';
|
15
|
+
import type { SListItem } from '../data-model/serialized/markdown.d.ts';
|
16
|
+
import type {
|
17
|
+
DataObject,
|
18
|
+
Grouping,
|
19
|
+
Link,
|
20
|
+
Literal,
|
21
|
+
Values,
|
22
|
+
Widgets
|
23
|
+
} from '../data-model/value.d.ts';
|
24
|
+
import type { Context } from '../expression/context.d.ts';
|
25
|
+
import type { BoundFunctionImpl } from '../expression/functions.d.ts';
|
26
|
+
import type { IdentifierMeaning } from '../query/engine.d.ts';
|
27
|
+
import type { Query } from '../query/query.d.ts';
|
28
|
+
import type {
|
29
|
+
DataviewSettings,
|
30
|
+
ExportSettings
|
31
|
+
} from '../settings.d.ts';
|
32
|
+
import type { DataArray } from './data-array.d.ts';
|
16
33
|
/** Asynchronous API calls related to file / system IO. */
|
17
34
|
export declare class DataviewIOApi {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
35
|
+
api: DataviewApi;
|
36
|
+
constructor(api: DataviewApi);
|
37
|
+
/** Load the contents of a CSV asynchronously, returning a data array of rows (or undefined if it does not exist). */
|
38
|
+
csv(path: Link | string, originFile?: string): Promise<DataArray<DataObject> | undefined>;
|
39
|
+
/** Asynchronously load the contents of any link or path in an Obsidian vault. */
|
40
|
+
load(path: Link | string, originFile?: string): Promise<string | undefined>;
|
41
|
+
/** Normalize a link or path relative to an optional origin file. Returns a textual fully-qualified-path. */
|
42
|
+
normalize(path: Link | string, originFile?: string): string;
|
26
43
|
}
|
27
44
|
/** Global API for accessing the Dataview API, executing dataview queries, and */
|
28
45
|
export declare class DataviewApi {
|
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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
46
|
+
app: App;
|
47
|
+
index: FullIndex;
|
48
|
+
settings: DataviewSettings;
|
49
|
+
private verNum;
|
50
|
+
/** Evaluation context which expressions can be evaluated in. */
|
51
|
+
evaluationContext: Context;
|
52
|
+
/** IO API which supports asynchronous loading of data directly. */
|
53
|
+
io: DataviewIOApi;
|
54
|
+
/** Dataview functions which can be called from DataviewJS. */
|
55
|
+
func: Record<string, BoundFunctionImpl>;
|
56
|
+
/** Value utility functions for comparisons and type-checking. */
|
57
|
+
value: typeof Values;
|
58
|
+
/** Widget utility functions for creating built-in widgets. */
|
59
|
+
widget: typeof Widgets;
|
60
|
+
/** Re-exporting of luxon for people who can't easily require it. Sorry! */
|
61
|
+
luxon: typeof Luxon;
|
62
|
+
constructor(app: App, index: FullIndex, settings: DataviewSettings, verNum: string);
|
63
|
+
/** Utilities to check the current Dataview version and compare it to SemVer version ranges. */
|
64
|
+
version: {
|
65
|
+
current: string;
|
66
|
+
compare: (op: CompareOperator, ver: string) => boolean;
|
67
|
+
satisfies: (range: string) => boolean;
|
68
|
+
};
|
69
|
+
/** Return an array of paths (as strings) corresponding to pages which match the query. */
|
70
|
+
pagePaths(query?: string, originFile?: string): DataArray<string>;
|
71
|
+
/** Map a page path to the actual data contained within that page. */
|
72
|
+
page(path: string | Link, originFile?: string): Record<string, Literal> | undefined;
|
73
|
+
/** Return an array of page objects corresponding to pages which match the source query. */
|
74
|
+
pages(query?: string, originFile?: string): DataArray<Record<string, Literal>>;
|
75
|
+
/** Remaps important metadata to add data arrays. */
|
76
|
+
private _addDataArrays;
|
77
|
+
/**
|
78
|
+
* Convert an input element or array into a Dataview data-array. If the input is already a data array,
|
79
|
+
* it is returned unchanged.
|
80
|
+
*/
|
81
|
+
array(raw: unknown): DataArray<any>;
|
82
|
+
/** Return true if the given value is a javascript array OR a dataview data array. */
|
83
|
+
isArray(raw: unknown): raw is DataArray<any> | Array<any>;
|
84
|
+
/** Return true if the given value is a dataview data array; this returns FALSE for plain JS arrays. */
|
85
|
+
isDataArray(raw: unknown): raw is DataArray<any>;
|
86
|
+
/** Create a dataview file link to the given path. */
|
87
|
+
fileLink(path: string, embed?: boolean, display?: string): Link;
|
88
|
+
/** Create a dataview section link to the given path. */
|
89
|
+
sectionLink(path: string, section: string, embed?: boolean, display?: string): Link;
|
90
|
+
/** Create a dataview block link to the given path. */
|
91
|
+
blockLink(path: string, blockId: string, embed?: boolean, display?: string): Link;
|
92
|
+
/** Attempt to extract a date from a string, link or date. */
|
93
|
+
date(pathlike: string | Link | DateTime): DateTime | null;
|
94
|
+
/** Attempt to extract a duration from a string or duration. */
|
95
|
+
duration(str: string | Duration): Duration | null;
|
96
|
+
/** Parse a raw textual value into a complex Dataview type, if possible. */
|
97
|
+
parse(value: string): Literal;
|
98
|
+
/** Convert a basic JS type into a Dataview type by parsing dates, links, durations, and so on. */
|
99
|
+
literal(value: any): Literal;
|
100
|
+
/** Deep clone the given literal, returning a new literal which is independent of the original. */
|
101
|
+
clone(value: Literal): Literal;
|
102
|
+
/**
|
103
|
+
* Compare two arbitrary JavaScript values using Dataview's default comparison rules. Returns a negative value if
|
104
|
+
* a < b, 0 if a = b, and a positive value if a > b.
|
105
|
+
*/
|
106
|
+
compare(a: any, b: any): number;
|
107
|
+
/** Return true if the two given JavaScript values are equal using Dataview's default comparison rules. */
|
108
|
+
equal(a: any, b: any): boolean;
|
109
|
+
/**
|
110
|
+
* Execute an arbitrary Dataview query, returning a query result which:
|
111
|
+
*
|
112
|
+
* 1. Indicates the type of query,
|
113
|
+
* 2. Includes the raw AST of the parsed query.
|
114
|
+
* 3. Includes the output in the form relevant to that query type.
|
115
|
+
*
|
116
|
+
* List queries will return a list of objects ({ id, value }); table queries return a header array
|
117
|
+
* and a 2D array of values; and task arrays return a Grouping<Task> type which allows for recursive
|
118
|
+
* task nesting.
|
119
|
+
*/
|
120
|
+
query(source: string | Query, originFile?: string, settings?: QueryApiSettings): Promise<Result<QueryResult, string>>;
|
121
|
+
/** Error-throwing version of {@link query}. */
|
122
|
+
tryQuery(source: string, originFile?: string, settings?: QueryApiSettings): Promise<QueryResult>;
|
123
|
+
/** Execute an arbitrary dataview query, returning the results in well-formatted markdown. */
|
124
|
+
queryMarkdown(source: string | Query, originFile?: string, settings?: Partial<QueryApiSettings & ExportSettings>): Promise<Result<string, string>>;
|
125
|
+
/** Error-throwing version of {@link queryMarkdown}. */
|
126
|
+
tryQueryMarkdown(source: string | Query, originFile?: string, settings?: Partial<QueryApiSettings & ExportSettings>): Promise<string>;
|
127
|
+
/**
|
128
|
+
* Evaluate a dataview expression (like '2 + 2' or 'link("hello")'), returning the evaluated result.
|
129
|
+
* This takes an optional second argument which provides definitions for variables, such as:
|
130
|
+
*
|
131
|
+
* ```
|
132
|
+
* dv.evaluate("x + 6", { x: 2 }) = 8
|
133
|
+
* dv.evaluate('link(target)', { target: "Okay" }) = [[Okay]]
|
134
|
+
* ```
|
135
|
+
*
|
136
|
+
* This method returns a Result type instead of throwing an error; you can check the result of the
|
137
|
+
* execution via `result.successful` and obtain `result.value` or `result.error` accordingly. If
|
138
|
+
* you'd rather this method throw on an error, use `dv.tryEvaluate`.
|
139
|
+
*/
|
140
|
+
evaluate(expression: string, context?: DataObject, originFile?: string): Result<Literal, string>;
|
141
|
+
/** Error-throwing version of `dv.evaluate`. */
|
142
|
+
tryEvaluate(expression: string, context?: DataObject, originFile?: string): Literal;
|
143
|
+
/** Evaluate an expression in the context of the given file. */
|
144
|
+
evaluateInline(expression: string, origin: string): Result<Literal, string>;
|
145
|
+
/**
|
146
|
+
* Execute the given query, rendering results into the given container using the components lifecycle.
|
147
|
+
* Your component should be a *real* component which calls onload() on it's child components at some point,
|
148
|
+
* or a MarkdownPostProcessorContext!
|
149
|
+
*
|
150
|
+
* Note that views made in this way are live updating and will automatically clean themselves up when
|
151
|
+
* the component is unloaded or the container is removed.
|
152
|
+
*/
|
153
|
+
execute(source: string, container: HTMLElement, component: Component | MarkdownPostProcessorContext, filePath: string): Promise<void>;
|
154
|
+
/**
|
155
|
+
* Execute the given DataviewJS query, rendering results into the given container using the components lifecycle.
|
156
|
+
* See {@link execute} for general rendering semantics.
|
157
|
+
*/
|
158
|
+
executeJs(code: string, container: HTMLElement, component: Component | MarkdownPostProcessorContext, filePath: string): Promise<void>;
|
159
|
+
/** Render a dataview list of the given values. */
|
160
|
+
list(values: any[] | DataArray<any> | undefined, container: HTMLElement, component: Component, filePath: string): Promise<void>;
|
161
|
+
/** Render a dataview table with the given headers, and the 2D array of values. */
|
162
|
+
table(headers: string[], values: any[][] | DataArray<any> | undefined, container: HTMLElement, component: Component, filePath: string): Promise<void>;
|
163
|
+
/** Render a dataview task view with the given tasks. */
|
164
|
+
taskList(tasks: Grouping<SListItem>, groupByFile: boolean | undefined, container: HTMLElement, component: Component, filePath?: string): Promise<void>;
|
165
|
+
/** Render an arbitrary value into a container. */
|
166
|
+
renderValue(value: any, container: HTMLElement, component: Component, filePath: string, inline?: boolean): Promise<void>;
|
167
|
+
/** Render data to a markdown table. */
|
168
|
+
markdownTable(headers: string[] | undefined, values: any[][] | DataArray<any> | undefined, settings?: Partial<ExportSettings>): string;
|
169
|
+
/** Render data to a markdown list. */
|
170
|
+
markdownList(values: any[] | DataArray<any> | undefined, settings?: Partial<ExportSettings>): string;
|
171
|
+
/** Render tasks or list items to a markdown task list. */
|
172
|
+
markdownTaskList(values: Grouping<SListItem>, settings?: Partial<ExportSettings>): string;
|
156
173
|
}
|
157
174
|
/** The result of executing a table query. */
|
158
175
|
export type TableResult = {
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
176
|
+
type: 'table';
|
177
|
+
headers: string[];
|
178
|
+
values: Literal[][];
|
179
|
+
idMeaning: IdentifierMeaning;
|
163
180
|
};
|
164
181
|
/** The result of executing a list query. */
|
165
182
|
export type ListResult = {
|
166
|
-
|
167
|
-
|
168
|
-
|
183
|
+
type: 'list';
|
184
|
+
values: Literal[];
|
185
|
+
primaryMeaning: IdentifierMeaning;
|
169
186
|
};
|
170
187
|
/** The result of executing a task query. */
|
171
188
|
export type TaskResult = {
|
172
|
-
|
173
|
-
|
189
|
+
type: 'task';
|
190
|
+
values: Grouping<SListItem>;
|
174
191
|
};
|
175
192
|
/** The result of executing a calendar query. */
|
176
193
|
export type CalendarResult = {
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
194
|
+
type: 'calendar';
|
195
|
+
values: {
|
196
|
+
date: DateTime;
|
197
|
+
link: Link;
|
198
|
+
value?: Literal[];
|
199
|
+
}[];
|
183
200
|
};
|
184
201
|
/** The result of executing a query of some sort. */
|
185
202
|
export type QueryResult = TableResult | ListResult | TaskResult | CalendarResult;
|
186
203
|
/** Settings when querying the dataview API. */
|
187
204
|
export type QueryApiSettings = {
|
188
|
-
|
189
|
-
|
205
|
+
/** If present, then this forces queries to include/exclude the implicit id field (such as with `WITHOUT ID`). */
|
206
|
+
forceId?: boolean;
|
190
207
|
};
|
191
208
|
/** Determines if source-path has a `?no-dataview` annotation that disables dataview. */
|
192
209
|
export declare function isDataviewDisabled(sourcePath: string): boolean;
|
@@ -1,38 +1,38 @@
|
|
1
1
|
/** Functional return type for error handling. */
|
2
2
|
export declare class Success<T, E> {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
value: T;
|
4
|
+
successful: true;
|
5
|
+
constructor(value: T);
|
6
|
+
map<U>(f: (a: T) => U): Result<U, E>;
|
7
|
+
flatMap<U>(f: (a: T) => Result<U, E>): Result<U, E>;
|
8
|
+
mapErr<U>(f: (e: E) => U): Result<T, U>;
|
9
|
+
bimap<T2, E2>(succ: (a: T) => T2, _fail: (b: E) => E2): Result<T2, E2>;
|
10
|
+
orElse(_value: T): T;
|
11
|
+
cast<U>(): Result<U, E>;
|
12
|
+
orElseThrow(_message?: (e: E) => string): T;
|
13
13
|
}
|
14
14
|
/** Functional return type for error handling. */
|
15
15
|
export declare class Failure<T, E> {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
error: E;
|
17
|
+
successful: false;
|
18
|
+
constructor(error: E);
|
19
|
+
map<U>(_f: (a: T) => U): Result<U, E>;
|
20
|
+
flatMap<U>(_f: (a: T) => Result<U, E>): Result<U, E>;
|
21
|
+
mapErr<U>(f: (e: E) => U): Result<T, U>;
|
22
|
+
bimap<T2, E2>(_succ: (a: T) => T2, fail: (b: E) => E2): Result<T2, E2>;
|
23
|
+
orElse(value: T): T;
|
24
|
+
cast<U>(): Result<U, E>;
|
25
|
+
orElseThrow(message?: (e: E) => string): T;
|
26
26
|
}
|
27
27
|
export type Result<T, E> = Success<T, E> | Failure<T, E>;
|
28
28
|
/** Monadic 'Result' type which encapsulates whether a procedure succeeded or failed, as well as it's return value. */
|
29
29
|
export declare namespace Result {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
/** Construct a new success result wrapping the given value. */
|
31
|
+
function success<T, E>(value: T): Result<T, E>;
|
32
|
+
/** Construct a new failure value wrapping the given error. */
|
33
|
+
function failure<T, E>(error: E): Result<T, E>;
|
34
|
+
/** Join two results with a bi-function and return a new result. */
|
35
|
+
function flatMap2<T1, T2, O, E>(first: Result<T1, E>, second: Result<T2, E>, f: (a: T1, b: T2) => Result<O, E>): Result<O, E>;
|
36
|
+
/** Join two results with a bi-function and return a new result. */
|
37
|
+
function map2<T1, T2, O, E>(first: Result<T1, E>, second: Result<T2, E>, f: (a: T1, b: T2) => O): Result<O, E>;
|
38
38
|
}
|
@@ -1,19 +1,19 @@
|
|
1
1
|
/** Parse inline fields and other embedded metadata in a line. */
|
2
|
-
import type { Literal } from
|
2
|
+
import type { Literal } from '../data-model/value.d.ts';
|
3
3
|
/** A parsed inline field. */
|
4
4
|
export interface InlineField {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
/** The raw parsed key. */
|
6
|
+
key: string;
|
7
|
+
/** The raw value of the field. */
|
8
|
+
value: string;
|
9
|
+
/** The start column of the field. */
|
10
|
+
start: number;
|
11
|
+
/** The start column of the *value* for the field. */
|
12
|
+
startValue: number;
|
13
|
+
/** The end column of the field. */
|
14
|
+
end: number;
|
15
|
+
/** If this inline field was defined via a wrapping ('[' or '('), then the wrapping that was used. */
|
16
|
+
wrapping?: string;
|
17
17
|
}
|
18
18
|
/** The wrapper characters that can be used to define an inline field. */
|
19
19
|
export declare const INLINE_FIELD_WRAPPERS: Readonly<Record<string, string>>;
|
@@ -34,8 +34,8 @@ export declare const DONE_DATE_REGEX: RegExp;
|
|
34
34
|
export declare const SCHEDULED_DATE_REGEX: RegExp;
|
35
35
|
export declare const START_DATE_REGEX: RegExp;
|
36
36
|
export declare const EMOJI_REGEXES: {
|
37
|
-
|
38
|
-
|
37
|
+
regex: RegExp;
|
38
|
+
key: string;
|
39
39
|
}[];
|
40
40
|
/** Sets or replaces the value of an inline field; if the value is 'undefined', deletes the key. */
|
41
41
|
export declare function setInlineField(source: string, key: string, value?: string): string;
|
@@ -1,8 +1,19 @@
|
|
1
1
|
/** Importer for markdown documents. */
|
2
|
-
import type {
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
import type {
|
3
|
+
CachedMetadata,
|
4
|
+
FileStats,
|
5
|
+
FrontMatterCache,
|
6
|
+
HeadingCache
|
7
|
+
} from 'obsidian';
|
8
|
+
import type { InlineField } from '../data-import/inline-field.d.ts';
|
9
|
+
import type {
|
10
|
+
ListItem,
|
11
|
+
PageMetadata
|
12
|
+
} from '../data-model/markdown.d.ts';
|
13
|
+
import type {
|
14
|
+
Link,
|
15
|
+
Literal
|
16
|
+
} from '../data-model/value.d.ts';
|
6
17
|
/** Extract markdown metadata from the given Obsidian markdown file. */
|
7
18
|
export declare function parsePage(path: string, contents: string, stat: FileStats, metadata: CachedMetadata): PageMetadata;
|
8
19
|
/** Extract tags intelligently from frontmatter. Handles arrays, numbers, and strings. */
|
@@ -13,15 +24,20 @@ export declare function extractAliases(metadata: FrontMatterCache): string[];
|
|
13
24
|
export declare function splitFrontmatterTagOrAlias(data: any, on: RegExp): string[];
|
14
25
|
/** Parse raw (newline-delimited) markdown, returning inline fields, list items, and other metadata. */
|
15
26
|
export declare function parseMarkdown(path: string, contents: string[], metadata: CachedMetadata, linksByLine: Record<number, Link[]>): {
|
16
|
-
|
17
|
-
|
27
|
+
fields: Map<string, Literal[]>;
|
28
|
+
lists: ListItem[];
|
18
29
|
};
|
19
30
|
export declare const LIST_ITEM_REGEX: RegExp;
|
20
31
|
/**
|
21
32
|
* Parse list items from the page + metadata. This requires some additional parsing above whatever Obsidian provides,
|
22
33
|
* since Obsidian only gives line numbers.
|
23
34
|
*/
|
24
|
-
export declare function parseLists(
|
35
|
+
export declare function parseLists(
|
36
|
+
path: string,
|
37
|
+
content: string[],
|
38
|
+
metadata: CachedMetadata,
|
39
|
+
linksByLine: Record<number, Link[]>
|
40
|
+
): [ListItem[], Map<string, Literal[]>];
|
25
41
|
/** Recursively convert frontmatter into fields. We have to dance around YAML structure. */
|
26
42
|
export declare function parseFrontmatter(value: any): Literal;
|
27
43
|
/** Add a parsed inline field to the output map. */
|
@@ -1,32 +1,32 @@
|
|
1
|
-
type LocalForage = typeof import(
|
1
|
+
type LocalForage = typeof import('localforage');
|
2
2
|
|
3
|
-
import type { PageMetadata } from
|
3
|
+
import type { PageMetadata } from '../data-model/markdown.d.ts';
|
4
4
|
/** A piece of data that has been cached for a specific version and time. */
|
5
5
|
export interface Cached<T> {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
/** The version of Dataview that the data was written to cache with. */
|
7
|
+
version: string;
|
8
|
+
/** The time that the data was written to cache. */
|
9
|
+
time: number;
|
10
|
+
/** The data that was cached. */
|
11
|
+
data: T;
|
12
12
|
}
|
13
13
|
/** Simpler wrapper for a file-backed cache for arbitrary metadata. */
|
14
14
|
export declare class LocalStorageCache {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
15
|
+
appId: string;
|
16
|
+
version: string;
|
17
|
+
persister: LocalForage;
|
18
|
+
constructor(appId: string, version: string);
|
19
|
+
/** Drop the entire cache instance and re-create a new fresh instance. */
|
20
|
+
recreate(): Promise<void>;
|
21
|
+
/** Load file metadata by path. */
|
22
|
+
loadFile(path: string): Promise<Cached<Partial<PageMetadata>> | null | undefined>;
|
23
|
+
/** Store file metadata by path. */
|
24
|
+
storeFile(path: string, data: Partial<PageMetadata>): Promise<void>;
|
25
|
+
/** Drop old file keys that no longer exist. */
|
26
|
+
synchronize(existing: string[] | Set<string>): Promise<Set<string>>;
|
27
|
+
/** Obtain a list of all metadata keys. */
|
28
|
+
allKeys(): Promise<string[]>;
|
29
|
+
/** Obtain a list of all persisted files. */
|
30
|
+
allFiles(): Promise<string[]>;
|
31
|
+
fileKey(path: string): string;
|
32
32
|
}
|
@@ -1,3 +1,6 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type {
|
2
|
+
CachedMetadata,
|
3
|
+
FileStats
|
4
|
+
} from 'obsidian';
|
5
|
+
import type { PageMetadata } from '../../data-model/markdown.d.ts';
|
3
6
|
export declare function runImport(path: string, contents: string, stats: FileStats, metadata: CachedMetadata): Partial<PageMetadata>;
|