Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/obsidian/scripts/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "path";
import { exec } from "child_process";
import util from "util";
// https://linear.app/discourse-graphs/issue/ENG-766/upgrade-all-commonjs-to-esm
// TODO: Change to apps/obsidian to ESM
// TODO if possible: change apps/obsidian to ESM. Use require until then.
// import { Octokit } from "@octokit/core";
const { Octokit } = require("@octokit/core");
import os from "os";
Expand Down Expand Up @@ -162,16 +162,16 @@ Release Type Auto-Detection:
BRAT Version Priority:
BRAT uses alphabetical ordering, so alpha < beta < stable
- 0.1.0-alpha-feature (lowest priority)
- 0.1.0-beta.1 (higher priority)
- 0.1.0-beta.1 (higher priority)
- 0.1.0 (highest priority)

Examples:
# Internal release with custom name
tsx scripts/publish-obsidian.ts --version 0.1.0-alpha-canvas --release-name "Canvas Integration Feature"

# Beta release with feature description
tsx scripts/publish-obsidian.ts --version 1.0.0-beta.1 --release-name "Beta: New Graph View"

# Stable release (uses default name)
tsx scripts/publish-obsidian.ts --version 1.0.0
`);
Expand Down
4 changes: 1 addition & 3 deletions apps/roam/scripts/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import * as path from "path";
import * as fs from "fs";
import { exec } from "child_process";
import util from "util";
// https://linear.app/discourse-graphs/issue/ENG-766/upgrade-all-commonjs-to-esm
// import { Octokit } from "@octokit/core";
// import { createAppAuth } from "@octokit/auth-app";
// Module configuration in roam does not allow ESM import, we need to use require here.
const { Octokit } = require("@octokit/core");
const { createAppAuth } = require("@octokit/auth-app");

Expand Down
41 changes: 20 additions & 21 deletions apps/roam/src/utils/cleanupOrphanedNodes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type SupabaseContext } from "./supabaseContext";
// https://linear.app/discourse-graphs/issue/ENG-766/upgrade-all-commonjs-to-esm
type DGSupabaseClient = any;
import type { SupabaseContext } from "./supabaseContext";
import type { DGSupabaseClient } from "@repo/database/lib/client";

const getAllNodesFromSupabase = async (
supabaseClient: DGSupabaseClient,
Expand All @@ -22,7 +21,7 @@ const getAllNodesFromSupabase = async (
return [];
}

const schemaIds = schemas.map((s: { id: string }) => s.id);
const schemaIds = schemas.map((s: { id: number }) => s.id);
let nodeResult: string[] = [];

if (schemaIds.length > 0) {
Expand Down Expand Up @@ -50,10 +49,10 @@ const getAllNodesFromSupabase = async (
nodeResult =
conceptResponse.data
?.map(
(c: { Content?: { source_local_id: string } }) =>
c.Content?.source_local_id,
(c: { Content?: { source_local_id: string | null } }) =>
c.Content?.source_local_id || null,
)
.filter((id: string): id is string => !!id) || [];
.filter((id: string | null): id is string => !!id) || [];
}

const blockContentResponse = await supabaseClient
Expand All @@ -73,8 +72,8 @@ const getAllNodesFromSupabase = async (

const blockResult =
blockContentResponse.data
?.map((c: { source_local_id: string }) => c.source_local_id)
.filter((id: string): id is string => !!id) || [];
?.map((c: { source_local_id: string | null }) => c.source_local_id)
.filter((id: string | null): id is string => !!id) || [];

const result = [...new Set([...nodeResult, ...blockResult])];

Expand Down Expand Up @@ -115,10 +114,10 @@ const getAllNodeSchemasFromSupabase = async (
return (
data
?.map(
(c: { Content?: { source_local_id: string } }) =>
c.Content?.source_local_id,
(c: { Content?: { source_local_id: string | null } }) =>
c.Content?.source_local_id || null,
)
.filter((id: string): id is string => !!id) || []
.filter((id: string | null): id is string => !!id) || []
);
} catch (error) {
console.error("Error in getAllNodeSchemasFromSupabase:", error);
Expand All @@ -133,7 +132,7 @@ const getNonExistentRoamUids = (nodeUids: string[]): string[] => {
}

const results = window.roamAlphaAPI.q(
`[:find ?uid
`[:find ?uid
:in $ [?uid ...]
:where (not [_ :block/uid ?uid])]`,
nodeUids,
Expand Down Expand Up @@ -162,7 +161,7 @@ const deleteNodesFromSupabase = async (
console.error("Failed to get content from Supabase:", contentError);
}

const contentIds = contentData?.map((c: { id: string }) => c.id) || [];
const contentIds = contentData?.map((c: { id: number }) => c.id) || [];

if (contentIds.length > 0) {
const { error: conceptError } = await supabaseClient
Expand Down Expand Up @@ -219,7 +218,7 @@ const deleteNodeSchemasFromSupabase = async (
return 0;
}

const schemaContentIds = schemaContentData.map((c: { id: string }) => c.id);
const schemaContentIds = schemaContentData.map((c: { id: number }) => c.id);

const { data: schemaConceptData, error: schemaConceptError } =
await supabaseClient
Expand All @@ -238,7 +237,7 @@ const deleteNodeSchemasFromSupabase = async (
}

const schemaConceptIds = (schemaConceptData || []).map(
(c: { id: string }) => c.id,
(c: { id: number }) => c.id,
);

let instanceConceptIds: number[] = [];
Expand All @@ -263,11 +262,11 @@ const deleteNodeSchemasFromSupabase = async (
}

instanceConceptIds = (instanceConceptData || []).map(
(ic: { id: string }) => ic.id,
(ic: { id: number }) => ic.id,
);
instanceContentIds = (instanceConceptData || [])
.map((ic: { represented_by_id: number }) => ic.represented_by_id)
.filter((x: number): x is number => typeof x === "number");
.map((ic: { represented_by_id: number | null }) => ic.represented_by_id)
.filter((x: number | null): x is number => typeof x === "number");

if (instanceContentIds.length > 0) {
const { data: instanceContentData, error: instanceContentLookupError } =
Expand All @@ -284,8 +283,8 @@ const deleteNodeSchemasFromSupabase = async (
return 0;
}
instanceSourceLocalIds = (instanceContentData || [])
.map((c: { source_local_id: string }) => c.source_local_id)
.filter((id: string): id is string => !!id);
.map((c: { source_local_id: string | null }) => c.source_local_id)
.filter((id: string | null): id is string => !!id);
}
}

Expand Down
16 changes: 8 additions & 8 deletions apps/roam/src/utils/syncDgNodesToSupabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import {
import { type OnloadArgs } from "roamjs-components/types";
import { fetchEmbeddingsForNodes } from "./upsertNodesAsContentWithEmbeddings";
import { convertRoamNodeToLocalContent } from "./upsertNodesAsContentWithEmbeddings";
// https://linear.app/discourse-graphs/issue/ENG-766/upgrade-all-commonjs-to-esm
type LocalContentDataInput = any;
type DGSupabaseClient = any;
type Json = any;
type AccountLocalInput = any;
import type { DGSupabaseClient } from "@repo/database/lib/client";
import type { Json, CompositeTypes } from "@repo/database/dbTypes";

type LocalContentDataInput = Partial<CompositeTypes<"content_local_input">>;
type AccountLocalInput = CompositeTypes<"account_local_input">;

const SYNC_FUNCTION = "embedding";
const SYNC_INTERVAL = "45s";
Expand Down Expand Up @@ -51,7 +51,7 @@ export const endSyncTask = async (
}
const { error } = await supabaseClient.rpc("end_sync_task", {
s_target: context.spaceId,
s_function: "embedding",
s_function: SYNC_FUNCTION,
s_worker: worker,
s_status: status,
});
Expand Down Expand Up @@ -157,7 +157,7 @@ const upsertNodeSchemaToContent = async ({
[?e :edit/time ?edit-time]
[?e :edit/user ?eu]
[(get-else $ ?eu :user/display-name "Unknown-person") ?author-name]

]
`;
//@ts-ignore - backend to be added to roamjs-components
Expand Down Expand Up @@ -311,7 +311,7 @@ const getDgNodeTypes = (extensionAPI: OnloadArgs["extensionAPI"]) => {
};

const getAllUsers = async (): Promise<AccountLocalInput[]> => {
const query = `[:find ?author_local_id ?author_name
const query = `[:find ?author_local_id ?author_name
:keys author_local_id name
:where
[?user-eid :user/uid ?author_local_id]
Expand Down
7 changes: 4 additions & 3 deletions apps/roam/src/utils/upsertNodesAsContentWithEmbeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import { type RoamDiscourseNodeData } from "./getAllDiscourseNodesSince";
import { type SupabaseContext } from "./supabaseContext";
import { nextApiRoot } from "@repo/utils/execContext";
type LocalContentDataInput = any;
type DGSupabaseClient = any;
type Json = any;
import type { DGSupabaseClient } from "@repo/database/lib/client";
import type { Json, CompositeTypes } from "@repo/database/dbTypes";

type LocalContentDataInput = Partial<CompositeTypes<"content_local_input">>;

const EMBEDDING_BATCH_SIZE = 200;
const EMBEDDING_MODEL = "openai_text_embedding_3_small_1536";
Expand Down