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
9 changes: 3 additions & 6 deletions cli/write-to-authcell.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Load .env file
import {
type CellLink,
getCellFromCellLink,
storage,
} from "@commontools/runner";
import { type CellLink, getCellFromLink, storage } from "@commontools/runner";
import { parseArgs } from "@std/cli/parse-args";

const TOOLSHED_API_URL = Deno.env.get("TOOLSHED_API_URL") ||
Expand All @@ -23,11 +19,12 @@ async function main(

const doc = await storage.syncCellById(replica, cellId, true);
const authCellEntity = {
space: replica,
cell: doc,
path: ["argument", "auth"],
} satisfies CellLink;

const authCell = getCellFromCellLink(replica, authCellEntity);
const authCell = getCellFromLink(authCellEntity);
// authCell.set({ token: "wat" });
await storage.synced();

Expand Down
14 changes: 7 additions & 7 deletions runner/src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,27 +214,27 @@ export function getCellFromEntityId(
return createCell(doc, path, log, schema);
}

export function getCellFromCellLink<T>(
space: string,
export function getCellFromLink<T>(
docLink: CellLink,
schema?: JSONSchema,
log?: ReactivityLog,
): Cell<T>;
export function getCellFromCellLink<S extends JSONSchema = JSONSchema>(
space: string,
export function getCellFromLink<S extends JSONSchema = JSONSchema>(
docLink: CellLink,
schema: S,
log?: ReactivityLog,
): Cell<Schema<S>>;
export function getCellFromCellLink(
space: string, // TODO(seefeld): Read from DocLink once it's defined there
export function getCellFromLink(
docLink: CellLink,
schema?: JSONSchema,
log?: ReactivityLog,
): Cell<any> {
if (!docLink.space) {
throw new Error("Cell link has no space");
}
const doc = isDoc(docLink.cell)
? docLink.cell
: getDocByEntityId(space, getEntityId(docLink.cell)!, true)!;
: getDocByEntityId(docLink.space, getEntityId(docLink.cell)!, true)!;
return createCell(doc, docLink.path, log, schema);
}

Expand Down
2 changes: 1 addition & 1 deletion runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export type { ReactivityLog } from "./scheduler.ts";
export { getDoc, isDoc } from "./doc.ts";
export {
getCell,
getCellFromCellLink,
getCellFromEntityId,
getCellFromLink,
getImmutableCell,
isCell,
isCellLink,
Expand Down
10 changes: 2 additions & 8 deletions toolshed/routes/integrations/google-oauth/google-oauth.utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { OAuth2Client } from "@cmd-johnson/oauth2-client";
import env from "@/env.ts";
import {
type CellLink,
getCellFromCellLink,
storage,
} from "@commontools/runner";
import { type CellLink, getCellFromLink, storage } from "@commontools/runner";
import { Context } from "@hono/hono";
import { Identity, Signer } from "@commontools/identity";
// Types
Expand Down Expand Up @@ -169,10 +165,8 @@ export async function getAuthCellAndStorage(docLink: CellLink | string) {

storage.setRemoteStorage(new URL("http://localhost:8000"));

// FIXME(ja): the space should be inferred from the doclink - but it isn't there yet
// FIXME(ja): add the authcell schema!
const authCell = getCellFromCellLink(
parsedDocLink.space, // FIXME(ja): the space should be inferred from the doclink - but it isn't there yet
const authCell = getCellFromLink(
parsedDocLink,
undefined,
);
Expand Down