Skip to content

Commit ff89481

Browse files
committed
upload data to blobby on data drop
1 parent e0c7331 commit ff89481

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

typescript/packages/lookslike-high-level/src/components/iframe-spell-ai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export async function iterate(charm: DocImpl<Charm> | null, value: string, shift
326326
}
327327

328328

329-
export async function createNewRecipe(data: any, newSpec: string) {
329+
export async function castNewRecipe(data: any, newSpec: string) {
330330
const schema = createJsonSchema({}, data);
331331
schema.description = newSpec;
332332

typescript/packages/lookslike-high-level/src/components/sidebar.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { customElement, property } from "lit/decorators.js";
33
import { style } from "@commontools/ui";
44
import { when } from "lit/directives/when.js";
55
import { Charm, charms, runPersistent } from "@commontools/charm";
6-
import { recipes } from "../data.js"
6+
import { BLOBBY_SERVER_URL, recipes } from "../data.js"
7+
import { refer } from "merkle-reference";
78

89
import {
910
getDoc,
@@ -22,6 +23,18 @@ import { render } from "@commontools/html";
2223
import { saveRecipe } from "../data.js";
2324
import { createNewRecipe } from "./iframe-spell-ai.js";
2425

26+
const uploadBlob = async (data: any) => {
27+
const id = refer(data).toString();
28+
29+
await fetch(`${BLOBBY_SERVER_URL}/data-${id}`, {
30+
method: "POST",
31+
headers: {
32+
"Content-Type": "application/json",
33+
},
34+
body: JSON.stringify(data),
35+
});
36+
};
37+
2538
// bf: TODO, send a "toast" event on window and an use another element to handle it
2639
const toasty = (message: string) => {
2740
const toastEl = document.createElement("div");
@@ -309,6 +322,9 @@ export class CommonSidebar extends LitElement {
309322
},
310323
};
311324

325+
// also posted the data json to blobby ... would spellcaster work with this data?
326+
uploadBlob(data);
327+
312328
await createNewRecipe(data, "a simple display of the users data");
313329
}
314330

typescript/packages/lookslike-high-level/src/components/window-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export class CommonWindowManager extends LitElement {
303303
const title = prompt("Enter a title for your recipe:");
304304
if (!title) return;
305305

306-
iframeSpellAi.createNewRecipe(data, title);
306+
iframeSpellAi.castNewRecipe(data, title);
307307
};
308308

309309
return html`

0 commit comments

Comments
 (0)