obsidian-confluence 5.6.12 → 5.6.14

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.
@@ -1,146 +1,144 @@
1
1
  import { Vault, MetadataCache, App, TFile } from "obsidian";
2
2
  import {
3
- ConfluenceUploadSettings,
4
- BinaryFile,
5
- FilesToUpload,
6
- LoaderAdaptor,
7
- MarkdownFile,
8
- ConfluencePageConfig,
3
+ ConfluenceUploadSettings,
4
+ BinaryFile,
5
+ FilesToUpload,
6
+ LoaderAdaptor,
7
+ MarkdownFile,
8
+ ConfluencePageConfig,
9
9
  } from "md-confluence-lib";
10
10
  import { lookup } from "mime-types";
11
11
 
12
12
  export default class ObsidianAdaptor implements LoaderAdaptor {
13
- vault: Vault;
14
- metadataCache: MetadataCache;
15
- settings: ConfluenceUploadSettings.ConfluenceSettings;
16
- app: App;
13
+ vault: Vault;
14
+ metadataCache: MetadataCache;
15
+ settings: ConfluenceUploadSettings.ConfluenceSettings;
16
+ app: App;
17
17
 
18
- constructor(
19
- vault: Vault,
20
- metadataCache: MetadataCache,
21
- settings: ConfluenceUploadSettings.ConfluenceSettings,
22
- app: App,
23
- ) {
24
- this.vault = vault;
25
- this.metadataCache = metadataCache;
26
- this.settings = settings;
27
- this.app = app;
28
- }
18
+ constructor(
19
+ vault: Vault,
20
+ metadataCache: MetadataCache,
21
+ settings: ConfluenceUploadSettings.ConfluenceSettings,
22
+ app: App,
23
+ ) {
24
+ this.vault = vault;
25
+ this.metadataCache = metadataCache;
26
+ this.settings = settings;
27
+ this.app = app;
28
+ }
29
29
 
30
- async getMarkdownFilesToUpload(): Promise<FilesToUpload> {
31
- const files = this.vault.getMarkdownFiles();
32
- const filesToPublish = [];
33
- for (const file of files) {
34
- try {
35
- if (file.path.endsWith(".excalidraw")) {
36
- continue;
37
- }
30
+ async getMarkdownFilesToUpload(): Promise<FilesToUpload> {
31
+ const files = this.vault.getMarkdownFiles();
32
+ const filesToPublish = [];
33
+ for (const file of files) {
34
+ try {
35
+ if (file.path.endsWith(".excalidraw")) {
36
+ continue;
37
+ }
38
38
 
39
- const fileFM = this.metadataCache.getCache(file.path);
40
- if (!fileFM) {
41
- throw new Error("Missing File in Metadata Cache");
42
- }
43
- const frontMatter = fileFM.frontmatter;
39
+ const fileFM = this.metadataCache.getCache(file.path);
40
+ if (!fileFM) {
41
+ throw new Error("Missing File in Metadata Cache");
42
+ }
43
+ const frontMatter = fileFM.frontmatter;
44
44
 
45
- if (
46
- (file.path.startsWith(this.settings.folderToPublish) &&
47
- (!frontMatter ||
48
- frontMatter["connie-publish"] !== false)) ||
49
- (frontMatter && frontMatter["connie-publish"] === true)
50
- ) {
51
- filesToPublish.push(file);
52
- }
53
- } catch {
54
- //ignore
55
- }
56
- }
57
- const filesToUpload = [];
45
+ if (
46
+ (file.path.startsWith(this.settings.folderToPublish) &&
47
+ (!frontMatter || frontMatter["connie-publish"] !== false)) ||
48
+ (frontMatter && frontMatter["connie-publish"] === true)
49
+ ) {
50
+ filesToPublish.push(file);
51
+ }
52
+ } catch {
53
+ //ignore
54
+ }
55
+ }
56
+ const filesToUpload = [];
58
57
 
59
- for (const file of filesToPublish) {
60
- const markdownFile = await this.loadMarkdownFile(file.path);
61
- filesToUpload.push(markdownFile);
62
- }
58
+ for (const file of filesToPublish) {
59
+ const markdownFile = await this.loadMarkdownFile(file.path);
60
+ filesToUpload.push(markdownFile);
61
+ }
63
62
 
64
- return filesToUpload;
65
- }
63
+ return filesToUpload;
64
+ }
66
65
 
67
- async loadMarkdownFile(absoluteFilePath: string): Promise<MarkdownFile> {
68
- const file = this.app.vault.getAbstractFileByPath(absoluteFilePath);
69
- if (!(file instanceof TFile)) {
70
- throw new Error("Not a TFile");
71
- }
66
+ async loadMarkdownFile(absoluteFilePath: string): Promise<MarkdownFile> {
67
+ const file = this.app.vault.getAbstractFileByPath(absoluteFilePath);
68
+ if (!(file instanceof TFile)) {
69
+ throw new Error("Not a TFile");
70
+ }
72
71
 
73
- const fileFM = this.metadataCache.getCache(file.path);
74
- if (!fileFM) {
75
- throw new Error("Missing File in Metadata Cache");
76
- }
77
- const frontMatter = fileFM.frontmatter;
72
+ const fileFM = this.metadataCache.getCache(file.path);
73
+ if (!fileFM) {
74
+ throw new Error("Missing File in Metadata Cache");
75
+ }
76
+ const frontMatter = fileFM.frontmatter;
78
77
 
79
- const parsedFrontMatter: Record<string, unknown> = {};
80
- if (frontMatter) {
81
- for (const [key, value] of Object.entries(frontMatter)) {
82
- parsedFrontMatter[key] = value;
83
- }
84
- }
78
+ const parsedFrontMatter: Record<string, unknown> = {};
79
+ if (frontMatter) {
80
+ for (const [key, value] of Object.entries(frontMatter)) {
81
+ parsedFrontMatter[key] = value;
82
+ }
83
+ }
85
84
 
86
- return {
87
- pageTitle: file.basename,
88
- folderName: file.parent.name,
89
- absoluteFilePath: file.path,
90
- fileName: file.name,
91
- contents: await this.vault.cachedRead(file),
92
- frontmatter: parsedFrontMatter,
93
- };
94
- }
85
+ return {
86
+ pageTitle: file.basename,
87
+ folderName: file.parent.name,
88
+ absoluteFilePath: file.path,
89
+ fileName: file.name,
90
+ contents: await this.vault.cachedRead(file),
91
+ frontmatter: parsedFrontMatter,
92
+ };
93
+ }
95
94
 
96
- async readBinary(
97
- path: string,
98
- referencedFromFilePath: string,
99
- ): Promise<BinaryFile | false> {
100
- const testing = this.metadataCache.getFirstLinkpathDest(
101
- path,
102
- referencedFromFilePath,
103
- );
104
- if (testing) {
105
- const files = await this.vault.readBinary(testing);
106
- const mimeType =
107
- lookup(testing.extension) || "application/octet-stream";
108
- return {
109
- contents: files,
110
- filePath: testing.path,
111
- filename: testing.name,
112
- mimeType: mimeType,
113
- };
114
- }
95
+ async readBinary(
96
+ path: string,
97
+ referencedFromFilePath: string,
98
+ ): Promise<BinaryFile | false> {
99
+ const testing = this.metadataCache.getFirstLinkpathDest(
100
+ path,
101
+ referencedFromFilePath,
102
+ );
103
+ if (testing) {
104
+ const files = await this.vault.readBinary(testing);
105
+ const mimeType = lookup(testing.extension) || "application/octet-stream";
106
+ return {
107
+ contents: files,
108
+ filePath: testing.path,
109
+ filename: testing.name,
110
+ mimeType: mimeType,
111
+ };
112
+ }
115
113
 
116
- return false;
117
- }
118
- async updateMarkdownValues(
119
- absoluteFilePath: string,
120
- values: Partial<ConfluencePageConfig.ConfluencePerPageAllValues>,
121
- ): Promise<void> {
122
- const config = ConfluencePageConfig.conniePerPageConfig;
123
- const file = this.app.vault.getAbstractFileByPath(absoluteFilePath);
124
- if (file instanceof TFile) {
125
- this.app.fileManager.processFrontMatter(file, (fm) => {
126
- for (const propertyKey in config) {
127
- if (!config.hasOwnProperty(propertyKey)) {
128
- continue;
129
- }
114
+ return false;
115
+ }
116
+ async updateMarkdownValues(
117
+ absoluteFilePath: string,
118
+ values: Partial<ConfluencePageConfig.ConfluencePerPageAllValues>,
119
+ ): Promise<void> {
120
+ const config = ConfluencePageConfig.conniePerPageConfig;
121
+ const file = this.app.vault.getAbstractFileByPath(absoluteFilePath);
122
+ if (file instanceof TFile) {
123
+ this.app.fileManager.processFrontMatter(file, (fm) => {
124
+ for (const propertyKey in config) {
125
+ if (!config.hasOwnProperty(propertyKey)) {
126
+ continue;
127
+ }
130
128
 
131
- const { key } =
132
- config[
133
- propertyKey as keyof ConfluencePageConfig.ConfluencePerPageConfig
134
- ];
135
- const value =
136
- values[
137
- propertyKey as keyof ConfluencePageConfig.ConfluencePerPageAllValues
138
- ];
139
- if (propertyKey in values) {
140
- fm[key] = value;
141
- }
142
- }
143
- });
144
- }
145
- }
129
+ const { key } =
130
+ config[
131
+ propertyKey as keyof ConfluencePageConfig.ConfluencePerPageConfig
132
+ ];
133
+ const value =
134
+ values[
135
+ propertyKey as keyof ConfluencePageConfig.ConfluencePerPageAllValues
136
+ ];
137
+ if (propertyKey in values) {
138
+ fm[key] = value;
139
+ }
140
+ }
141
+ });
142
+ }
143
+ }
146
144
  }
package/src/custom.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  declare module "*.txt" {
2
- const content: string;
3
- export default content;
2
+ const content: string;
3
+ export default content;
4
4
  }
5
5
 
6
6
  declare module "*.json" {
7
- const content: unknown;
8
- export default content;
7
+ const content: unknown;
8
+ export default content;
9
9
  }
10
10
 
11
11
  declare module "mermaid_renderer.esbuild" {
12
- const content: Buffer;
13
- export default content;
12
+ const content: Buffer;
13
+ export default content;
14
14
  }
15
15
 
16
16
  declare module "sort-any" {
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- export default function sortAny<T>(item: T): T;
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ export default function sortAny<T>(item: T): T;
19
19
  }