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
3 changes: 3 additions & 0 deletions typescript/packages/common-cli/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"memorydemo": "deno run --allow-read --allow-env --allow-net memory_demo.ts",
"test": "deno test",
"charmdemo": "deno run --allow-read --allow-env --allow-net charm_demo.ts"
},
"imports": {
"open": "https://deno.land/x/open@v0.0.6/index.ts"
}
}
6 changes: 2 additions & 4 deletions typescript/packages/common-cli/gcal.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { OAuth2Client } from "jsr:@cmd-johnson/oauth2-client@^2.0.0";
import { serve } from "https://deno.land/std@0.216.0/http/server.ts";
import { open } from "https://deno.land/x/open@v0.0.6/index.ts";
import { OAuth2Client } from "@cmd-johnson/oauth2-client";
import { load } from "@std/dotenv";
import { getAccessToken } from "./google.ts";

import { load } from "https://deno.land/std@0.216.0/dotenv/mod.ts";
const env = await load({
envPath: "./.env",
// you can also specify multiple possible paths:
Expand Down
22 changes: 16 additions & 6 deletions typescript/packages/common-cli/google-importer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Load .env file
import { parseArgs } from "jsr:@std/cli/parse-args";
import { parseArgs } from "@std/cli/parse-args";
import { CharmManager, setBobbyServerUrl, storage } from "@commontools/charm";
import { Cell, getEntityId, isStream } from "@commontools/runner";
import { Charm } from "@commontools/charm";
Expand All @@ -11,9 +11,13 @@ function showHelp() {
console.log("Usage: deno run main.ts [options]");
console.log("");
console.log("Options:");
console.log(" --space=<space> Space to watch (default: common-knowledge)");
console.log(
" --space=<space> Space to watch (default: common-knowledge)",
);
console.log(" --charmId=<id> Specific charm ID to watch");
console.log(" --interval=<seconds> Update interval in seconds (default: 30)");
console.log(
" --interval=<seconds> Update interval in seconds (default: 30)",
);
console.log(" --help Show this help message");
console.log(" --version Show version information");
Deno.exit(0);
Expand All @@ -31,7 +35,8 @@ const { space, charmId, interval } = flags;

// Configuration
const CHECK_INTERVAL = parseInt(interval as string) * 1000;
const toolshedUrl = Deno.env.get("TOOLSHED_API_URL") ?? "https://toolshed.saga-castor.ts.net/";
const toolshedUrl = Deno.env.get("TOOLSHED_API_URL") ??
"https://toolshed.saga-castor.ts.net/";

// Initialize storage and Bobby server
storage.setRemoteStorage(new URL(toolshedUrl));
Expand Down Expand Up @@ -90,7 +95,10 @@ async function refreshAuthToken(auth: Cell<any>, charm: Cell<Charm>) {
authCellId.space = space as string;
log(charm, `token expired, refreshing: ${authCellId}`);

const refresh_url = new URL("/api/integrations/google-oauth/refresh", toolshedUrl);
const refresh_url = new URL(
"/api/integrations/google-oauth/refresh",
toolshedUrl,
);
const refresh_response = await fetch(refresh_url, {
method: "POST",
body: JSON.stringify({ authCellId }),
Expand Down Expand Up @@ -149,7 +157,9 @@ async function watchCharm(charmId: string | undefined) {
}

function getId(charmId: string | Cell<Charm> | undefined): string | undefined {
const realCharmId = typeof charmId === "string" ? charmId : getEntityId(charmId)?.["/"];
const realCharmId = typeof charmId === "string"
? charmId
: getEntityId(charmId)?.["/"];
if (!realCharmId) {
log(undefined, "charmId not found", JSON.stringify(charmId));
return undefined;
Expand Down
9 changes: 4 additions & 5 deletions typescript/packages/common-cli/google.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { serve } from "https://deno.land/std@0.216.0/http/server.ts";
import { open } from "https://deno.land/x/open@v0.0.6/index.ts";
import { OAuth2Client } from "jsr:@cmd-johnson/oauth2-client@^2.0.0";
import { open } from "open";
import { OAuth2Client } from "@cmd-johnson/oauth2-client";

export async function getAccessToken(client: OAuth2Client) {
let authCode: string | null = null;
const controller = new AbortController();
const server = serve(
const server = Deno.serve(
{ port: 8080, signal: controller.signal },
(req) => {
const url = new URL(req.url);
if (url.searchParams.has("code")) {
Expand All @@ -17,7 +17,6 @@ export async function getAccessToken(client: OAuth2Client) {
}
return new Response("Waiting for authentication...");
},
{ port: 8080, signal: controller.signal },
);

const { uri, codeVerifier } = await client.code.getAuthorizationUri();
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-cli/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Load .env file
import { parseArgs } from "https://deno.land/std@0.224.0/cli/parse_args.ts";
import { parseArgs } from "@std/cli/parse-args";
import {
CharmManager,
compileRecipe,
Expand Down
4 changes: 2 additions & 2 deletions typescript/packages/common-cli/notes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { walk } from "https://deno.land/std@0.216.0/fs/walk.ts";
import { debounce } from "https://deno.land/std@0.216.0/async/debounce.ts";
import { walk } from "@std/fs";
import { debounce } from "@std/async/debounce";

export interface NoteChange {
path: string;
Expand Down
15 changes: 10 additions & 5 deletions typescript/packages/common-cli/write-to-authcell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import { CharmManager, compileRecipe, createStorage } from "@commontools/charm";
import { getEntityId, idle } from "@commontools/runner";
import { fetchInboxEmails } from "./gmail.ts";
import { parse } from "https://deno.land/std/flags/mod.ts";
import { parseArgs } from "@std/cli/parse-args";

import { getCellFromDocLink } from "@commontools/runner";

const TOOLSHED_API_URL = Deno.env.get("TOOLSHED_API_URL") || "https://toolshed.saga-castor.ts.net";
const TOOLSHED_API_URL = Deno.env.get("TOOLSHED_API_URL") ||
"https://toolshed.saga-castor.ts.net";

async function main(
recipeSrc: string,
Expand All @@ -20,7 +21,9 @@ async function main(
url: new URL(TOOLSHED_API_URL),
});

const cellId = { "/": "baedreiajxdvqjxmgpfzjix4h6vd4pl77unvet2k3acfvhb6ottafl7gpua" };
const cellId = {
"/": "baedreiajxdvqjxmgpfzjix4h6vd4pl77unvet2k3acfvhb6ottafl7gpua",
};

await storage.syncCell(cellId, true);
const authCellEntity = {
Expand Down Expand Up @@ -74,7 +77,7 @@ async function main(
// console.log({ emails });
}

const flags = parse(Deno.args, {
const flags = parseArgs(Deno.args, {
string: ["replica", "cause", "data"],
default: {
replica: "common-knowledge",
Expand All @@ -90,7 +93,9 @@ let jsonData: unknown;

if (!filename) {
console.error("No typescript recipe file provided");
console.error("Usage: deno run -A main.ts <recipe-file> [--replica=name] [--cause=id]");
console.error(
"Usage: deno run -A main.ts <recipe-file> [--replica=name] [--cause=id]",
);
Deno.exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/deno.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Provider from "./provider.ts";
import * as Socket from "./socket.ts";
import * as Path from "jsr:@std/path";
import * as Path from "@std/path";
import * as UCAN from "./ucan.ts";
import * as Receipt from "./receipt.ts";

Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/memory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Space from "./space.ts";
import * as Error from "./error.ts";
import * as FS from "jsr:@std/fs";
import * as FS from "@std/fs";
import {
AsyncResult,
ConnectionError,
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Database,
SqliteError,
Transaction as DBTransaction,
} from "jsr:@db/sqlite";
} from "@db/sqlite";

const MIGRATIONS = new URL("./migrations/", import.meta.url);

Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Database,
SqliteError,
Transaction as DBTransaction,
} from "jsr:@db/sqlite";
} from "@db/sqlite";
import { fromString, refer } from "./reference.ts";
import { unclaimed } from "./fact.ts";
import { from as toChanges, set } from "./changes.ts";
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/test/access-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, assertEquals, assertMatch } from "jsr:@std/assert";
import { assert, assertEquals, assertMatch } from "@std/assert";
import { alice, bob, mallory, space } from "./principal.ts";
import * as Access from "../access.ts";
import { refer } from "../reference.ts";
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/test/consumer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
assertEquals,
assertMatch,
assertObjectMatch,
} from "jsr:@std/assert";
} from "@std/assert";
import * as Fact from "../fact.ts";
import * as Transaction from "../transaction.ts";
import * as Changes from "../changes.ts";
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/test/memory-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, assertEquals, assertMatch } from "jsr:@std/assert";
import { assert, assertEquals, assertMatch } from "@std/assert";
import * as Memory from "../memory.ts";
import * as Fact from "../fact.ts";
import * as Transaction from "../transaction.ts";
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/test/space-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, assertEquals, assertMatch } from "jsr:@std/assert";
import { assert, assertEquals, assertMatch } from "@std/assert";
import * as Space from "../space.ts";
import * as Changes from "../changes.ts";
import * as Commit from "../commit.ts";
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/common-memory/test/stress-debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
assertEquals,
AssertionError,
assertMatch,
} from "jsr:@std/assert";
} from "@std/assert";
import * as Provider from "../provider.ts";
import * as Transaction from "../transaction.ts";
import * as Changes from "../changes.ts";
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/deno-web-test/browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Browser, ConsoleEvent, launch, Page } from "jsr:@astral/astral";
import { Browser, ConsoleEvent, launch, Page } from "@astral/astral";
import { Manifest } from "./manifest.ts";
import { tsToJs, wait } from "./utils.ts";
import { TestResult } from "./interface.ts";
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/deno-web-test/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseArgs } from "jsr:@std/cli/parse-args";
import { parseArgs } from "@std/cli/parse-args";
import { TestServer } from "./server.ts";
import { Manifest } from "./manifest.ts";
import { buildTestDir } from "./utils.ts";
Expand Down
18 changes: 11 additions & 7 deletions typescript/packages/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"],
"include": ["ban-untagged-todo", "no-external-import"],
"exclude": ["no-unused-vars", "no-explicit-any"]
}
},
Expand All @@ -48,6 +48,7 @@
"ai": "npm:ai@^4.1.5",
"@astral/astral": "jsr:@astral/astral",
"@cfworker/json-schema": "npm:@cfworker/json-schema@^4.1.0",
"@cmd-johnson/oauth2-client": "jsr:@cmd-johnson/oauth2-client@^2.0.0",
"@codemirror/lang-javascript": "npm:@codemirror/lang-javascript@^6.2.2",
"@codemirror/lang-markdown": "npm:@codemirror/lang-markdown@^6.3.2",
"@hono/hono": "npm:hono@^4.7.0",
Expand All @@ -58,13 +59,16 @@
"react": "npm:react@^18.3.1",
"@scure/bip39": "npm:@scure/bip39@^1.5.4",
"@std/assert": "jsr:@std/assert@^1",
"@std/crypto": "jsr:@std/crypto@^1.0.3",
"@std/async": "jsr:@std/async@^1",
"@std/cli": "jsr:@std/cli@^1",
"@std/crypto": "jsr:@std/crypto@^1",
"@std/dotenv": "jsr:@std/dotenv@^0.225.3",
"@std/encoding": "jsr:@std/encoding@^1.0.5",
"@std/expect": "jsr:@std/expect",
"@std/fs": "jsr:@std/fs@^1.0.9",
"@std/path": "jsr:@std/path@^1.0.8",
"@std/testing": "jsr:@std/testing",
"@std/encoding": "jsr:@std/encoding@^1",
"@std/expect": "jsr:@std/expect@^1",
"@std/fs": "jsr:@std/fs@^1",
"@std/http": "jsr:@std/http@^1",
"@std/path": "jsr:@std/path@^1",
"@std/testing": "jsr:@std/testing@^1",
"@vercel/otel": "npm:@vercel/otel@^1.10.1",
"typescript": "npm:typescript",
"@web/test-runner": "npm:@web/test-runner",
Expand Down
42 changes: 21 additions & 21 deletions typescript/packages/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typescript/packages/scripts/test-all.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env -S deno run --allow-read --allow-run
import * as path from "jsr:@std/path";
import * as path from "@std/path";

const decoder = new TextDecoder();
const workspaceCwd = Deno.cwd();
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/toolshed/env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import * as Path from "jsr:@std/path";
import * as Path from "@std/path";

// NOTE: This is where we define the environment variable types and defaults.
const EnvSchema = z.object({
Expand Down
Loading