Skip to content

Commit b73b1a1

Browse files
authored
Merge branch 'main' into workflows01
2 parents 8e20758 + 6b83a88 commit b73b1a1

57 files changed

Lines changed: 4523 additions & 1337 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/obsidian/src/components/ImportNodesModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { StrictMode, useState, useEffect, useCallback } from "react";
44
import type DiscourseGraphPlugin from "../index";
55
import type { ImportableNode, GroupWithNodes } from "~/types";
66
import { getUserNameById } from "~/utils/typeUtils";
7+
import { getAvailableGroupIds } from "@repo/database/lib/groups";
78
import {
89
fetchUserNames,
9-
getAvailableGroupIds,
1010
getPublishedNodesForGroups,
1111
getLocalNodeInstanceIds,
1212
getSpaceNameFromIds,

apps/obsidian/src/components/NodeTypeSettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ const NodeTypeSettings = () => {
12341234
void createBaseForNodeType(plugin, editingNodeType)
12351235
}
12361236
>
1237-
Create Base view
1237+
Create new Base view
12381238
</button>
12391239
</div>
12401240
</div>

apps/obsidian/src/components/PublishGroupDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
publishToSelectedGroupWithNotice,
1212
withPublishedState,
1313
} from "~/utils/publishGroupSelection";
14-
import type { MyGroup } from "~/utils/importNodes";
14+
import type { MyGroup } from "@repo/database/lib/groups";
1515

1616
type PublishGroupDropdownProps = {
1717
plugin: DiscourseGraphPlugin;

apps/obsidian/src/services/QueryEngine.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export class QueryEngine {
287287
matchedNodeType,
288288
alternativePattern: pattern.alternativePattern,
289289
extractedContent,
290-
selected: true,
290+
selected: false,
291291
});
292292
}
293293
break; // Stop checking other patterns for this file
@@ -374,7 +374,7 @@ export class QueryEngine {
374374
if (opts?.excludeImported) {
375375
const fm = this.app.metadataCache.getFileCache(file)
376376
?.frontmatter as Record<string, unknown> | undefined;
377-
if (fm?.importedFromRid || fm?.importedFromSpaceUri) continue;
377+
if (fm?.importedFromRid) continue;
378378
}
379379
files.push(file);
380380
}
@@ -528,13 +528,14 @@ export class QueryEngine {
528528
const files: TFile[] = [];
529529
const allFiles = this.app.vault.getMarkdownFiles();
530530
for (const f of allFiles) {
531-
const fm = this.app.metadataCache.getFileCache(f)?.frontmatter;
532-
const nodeTypeId = (fm as Record<string, unknown> | undefined)
533-
?.nodeTypeId;
531+
const fm = this.app.metadataCache.getFileCache(f)?.frontmatter as
532+
| Record<string, unknown>
533+
| undefined;
534+
const nodeTypeId = fm?.nodeTypeId;
534535
if (!nodeTypeId) continue;
535536
if (
536537
opts?.excludeImported &&
537-
(fm as Record<string, unknown>)?.importedFromRid
538+
(fm?.importedFromRid || fm?.importedFromSpaceUri)
538539
) {
539540
continue;
540541
}
@@ -590,7 +591,7 @@ export class QueryEngine {
590591
matchedNodeType,
591592
alternativePattern: pattern.alternativePattern,
592593
extractedContent,
593-
selected: true,
594+
selected: false,
594595
});
595596
break;
596597
}

apps/obsidian/src/utils/getDiscourseNodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type DiscourseNodeInVault = {
1313
/**
1414
* Collect all discourse nodes from the vault.
1515
* Uses DataCore when available; falls back to vault iteration otherwise.
16-
* When includeImported is false (default), excludes files with importedFromRid/importedFromSpaceUri.
16+
* When includeImported is false (default), excludes files with importedFromRid.
1717
*/
1818
export const collectDiscourseNodesFromVault = async (
1919
plugin: DiscourseGraphPlugin,

apps/obsidian/src/utils/importNodes.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,6 @@ import {
2121
import { createTemplateFile } from "./templates";
2222
import { resolveFolderForSpaceUri } from "./importFolderMetadata";
2323

24-
export type MyGroup = {
25-
id: string;
26-
name: string;
27-
};
28-
29-
export const getAvailableGroupIds = async (
30-
client: DGSupabaseClient,
31-
): Promise<string[]> => {
32-
const { data, error } = await client
33-
.from("group_membership")
34-
.select("group_id")
35-
.eq("member_id", (await client.auth.getUser()).data.user?.id || "");
36-
37-
if (error) {
38-
console.error("Error fetching groups:", error);
39-
throw new Error(`Failed to fetch groups: ${error.message}`);
40-
}
41-
42-
return (data || []).map((g) => g.group_id);
43-
};
44-
45-
export const getMyGroups = async (
46-
client: DGSupabaseClient,
47-
): Promise<MyGroup[]> => {
48-
const userId = (await client.auth.getUser()).data.user?.id ?? "";
49-
const { data, error } = await client
50-
.from("group_membership")
51-
.select("group_id, my_groups!group_id(name)")
52-
.eq("member_id", userId);
53-
54-
if (error) {
55-
console.error("Error fetching groups:", error);
56-
throw new Error(`Failed to fetch groups: ${error.message}`);
57-
}
58-
59-
return (data ?? [])
60-
.filter(
61-
(row): row is { group_id: string; my_groups: { name: string | null } } =>
62-
typeof row.group_id === "string" &&
63-
row.my_groups !== null &&
64-
typeof row.my_groups === "object",
65-
)
66-
.map((row) => ({
67-
id: row.group_id,
68-
name: row.my_groups.name ?? row.group_id,
69-
}));
70-
};
71-
7224
type PublishedNode = {
7325
source_local_id: string;
7426
space_id: number;

apps/obsidian/src/utils/publishGroupSelection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Notice, type FrontMatterCache, type TFile } from "obsidian";
2-
import type DiscourseGraphPlugin from "~/index";
3-
import { PublishGroupSuggestModal } from "~/components/PublishGroupSuggestModal";
42
import {
53
getAvailableGroupIds,
64
getMyGroups,
75
type MyGroup,
8-
} from "~/utils/importNodes";
6+
} from "@repo/database/lib/groups";
7+
import type DiscourseGraphPlugin from "~/index";
8+
import { PublishGroupSuggestModal } from "~/components/PublishGroupSuggestModal";
99
import { getLoggedInClient } from "~/utils/supabaseContext";
1010
import {
1111
getPublishedToGroups,

apps/obsidian/src/utils/publishNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type RelationsFile,
1212
} from "./relationsStore";
1313
import type { RelationInstance } from "~/types";
14-
import { getAvailableGroupIds } from "./importNodes";
14+
import { getAvailableGroupIds } from "@repo/database/lib/groups";
1515
import {
1616
syncAllNodesAndRelations,
1717
syncPublishedNodeAssets,

apps/obsidian/src/utils/templateImport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable @typescript-eslint/naming-convention -- Supabase query results use snake_case column names */
22
import type { Json } from "@repo/database/dbTypes";
3+
import { getAvailableGroupIds } from "@repo/database/lib/groups";
34
import type DiscourseGraphPlugin from "~/index";
45
import {
56
fetchUserNames,
6-
getAvailableGroupIds,
77
getSpaceNameFromIds,
88
getSpaceUris,
99
} from "./importNodes";

apps/obsidian/src/utils/upsertNodesAsContentWithEmbeddings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const createNodeContentEntries = async (
6363
...baseEntry,
6464
text: node.file.basename,
6565
variant: "direct",
66+
content_type: "text/plain",
6667
metadata: { filePath: node.file.path },
6768
});
6869
}
@@ -75,6 +76,7 @@ const createNodeContentEntries = async (
7576
...baseEntry,
7677
text: fullContent,
7778
variant: "full",
79+
content_type: "text/obsidian+markdown",
7880
metadata: node.frontmatter as Json,
7981
});
8082
} catch (error) {

0 commit comments

Comments
 (0)