Skip to content

Commit 842890e

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/signed-transactions
2 parents 73fe05a + 32ea676 commit 842890e

Some content is hidden

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

62 files changed

+388
-256
lines changed

typescript/packages/common-builder/src/built-in.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const navigateTo = createNodeFactory({
6464
// Example:
6565
// str`Hello, ${name}!`
6666
//
67-
// TODO: This should be a built-in module
67+
// TODO(seefeld): This should be a built-in module
6868
export function str(
6969
strings: TemplateStringsArray,
7070
...values: any[]

typescript/packages/common-builder/src/opaque-ref.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function opaqueRef<T>(value?: Opaque<T> | T): OpaqueRef<T> {
4848
get: () => unsafe_materialize(unsafe_binding, path),
4949
set: (newValue: Opaque<any>) => {
5050
if (unsafe_binding) {
51-
unsafe_materialize(unsafe_binding, path); // TODO: Set value
51+
unsafe_materialize(unsafe_binding, path); // TODO(seefeld): Set value
5252
} else setValueAtPath(store, ["value", ...path], newValue);
5353
},
5454
key: (key: PropertyKey) => createNestedProxy([...path, key]),
@@ -101,7 +101,7 @@ export function opaqueRef<T>(value?: Opaque<T> | T): OpaqueRef<T> {
101101
),
102102
});
103103
},
104-
toJSON: () => null, // TODO: Merge with Cell and cover doc-less case
104+
toJSON: () => null, // TODO(seefeld): Merge with Cell and cover doc-less case
105105
/**
106106
* We assume the cell is an array and will provide an infinite iterator.
107107
* The primary use-case is destructuring a tuple (`[a, b] = ...`). We

typescript/packages/common-builder/src/recipe.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function factoryFromRecipe<T, R>(
204204
paths.set(inputs, ["argument"]);
205205

206206
// Add paths for all the internal cells
207-
// TODO: Infer more stable identifiers
207+
// TODO(seefeld): Infer more stable identifiers
208208
let count = 0;
209209
cells.forEach((cell: OpaqueRef<any>) => {
210210
if (paths.has(cell)) return;
@@ -249,12 +249,12 @@ function factoryFromRecipe<T, R>(
249249
let argumentSchema: JSONSchema;
250250

251251
if (typeof argumentSchemaArg === "string") {
252-
// TODO: initial is likely not needed anymore
253-
// TODO: But we need a new one for the result
252+
// TODO(seefeld): initial is likely not needed anymore
253+
// TODO(seefeld): But we need a new one for the result
254254
argumentSchema = createJsonSchema(defaults, {});
255255
argumentSchema.description = argumentSchemaArg;
256256

257-
delete argumentSchema.properties?.[UI]; // TODO: This should be a schema for views
257+
delete argumentSchema.properties?.[UI]; // TODO(seefeld): This should be a schema for views
258258
if (argumentSchema.properties?.internal?.properties) {
259259
for (
260260
const key of Object.keys(
@@ -314,7 +314,7 @@ function factoryFromRecipe<T, R>(
314314
}, recipe) satisfies RecipeFactory<T, R>;
315315

316316
// Bind all cells to the recipe
317-
// TODO: Does OpaqueRef cause issues here?
317+
// TODO(seefeld): Does OpaqueRef cause issues here?
318318
[...cells]
319319
.filter((cell) => !cell.export().path.length) // Only bind root cells
320320
.forEach((cell) =>

typescript/packages/common-builder/src/spell.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { derive, type OpaqueRef, recipe, stream, UI } from "./index.ts";
66

77
type PathSegment = PropertyKey | { fn: string; args: any[] };
88
const getPath = Symbol("getPath");
9-
type PathCollector = Function & {
9+
type PathCollector = ((this: any, ...args: any[]) => any) & {
1010
[getPath]: PathSegment[];
1111
[key: string]: PathCollector;
1212
};
@@ -44,7 +44,7 @@ function createPathCollector(path: PathSegment[] = []): PathCollector {
4444
export const $ = createPathCollector();
4545

4646
// Resolve $ to a paths on `self`
47-
// TODO: Also for non-top-level ones
47+
// TODO(seefeld): Also for non-top-level ones
4848
function resolve$(self: OpaqueRef<any>, query: PathCollector) {
4949
const entries = Object.entries(query);
5050
const result: Record<string, any> = {};

typescript/packages/common-builder/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function isStreamAlias(value: any): value is StreamAlias {
138138

139139
export type Module = {
140140
type: "ref" | "javascript" | "recipe" | "raw" | "isolated" | "passthrough";
141-
implementation?: Function | Recipe | string;
141+
implementation?: ((...args: any[]) => any) | Recipe | string;
142142
wrapper?: "handler";
143143
argumentSchema?: JSONSchema;
144144
resultSchema?: JSONSchema;

typescript/packages/common-builder/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export function createJsonSchema(
236236
if (Array.isArray(value ?? defaultValue)) {
237237
schema.type = "array";
238238
if ((value ?? defaultValue).length > 0) {
239-
let properties: { [key: string]: any } = {};
239+
const properties: { [key: string]: any } = {};
240240
for (let i = 0; i < (value ?? defaultValue).length; i++) {
241241
const item = value?.[i] ?? defaultValue?.[i];
242242
if (typeof item === "object" && item !== null) {

typescript/packages/common-charm/src/charm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class CharmManager {
127127
},
128128
};
129129
if (hasUI && !resultSchema.properties![UI]) {
130-
resultSchema.properties![UI] = { type: "object" }; // TODO: vdom schema
130+
resultSchema.properties![UI] = { type: "object" }; // TODO(seefeld): make this the vdom schema
131131
}
132132
if (hasName && !resultSchema.properties![NAME]) {
133133
resultSchema.properties![NAME] = { type: "string" };

typescript/packages/common-charm/src/iterate.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import { Charm, CharmManager } from "./charm.ts";
77
import { buildFullRecipe, getIframeRecipe } from "./iframe/recipe.ts";
88
import { buildPrompt } from "./iframe/prompt.ts";
99

10-
const llmUrl = typeof window !== "undefined"
11-
? window.location.protocol + "//" + window.location.host + "/api/ai/llm"
10+
const llmUrl = typeof globalThis.location !== "undefined"
11+
? globalThis.location.protocol + "//" + globalThis.location.host +
12+
"/api/ai/llm"
1213
: "//api/ai/llm";
1314

1415
const llm = new LLMClient(llmUrl);
@@ -93,7 +94,7 @@ export const saveNewRecipeVersion = async (
9394
name,
9495
});
9596

96-
return compileAndRunRecipe(
97+
return await compileAndRunRecipe(
9798
charmManager,
9899
newRecipeSrc,
99100
newSpec,
@@ -121,7 +122,7 @@ export async function castNewRecipe(
121122
name,
122123
});
123124

124-
return compileAndRunRecipe(charmManager, newRecipeSrc, newSpec, data);
125+
return await compileAndRunRecipe(charmManager, newRecipeSrc, newSpec, data);
125126
}
126127

127128
export async function compileRecipe(
@@ -157,7 +158,7 @@ export async function compileAndRunRecipe(
157158
}
158159

159160
const newCharm = await charmManager.runPersistent(recipe, runOptions);
160-
charmManager.add([newCharm]);
161+
await charmManager.add([newCharm]);
161162
await charmManager.syncRecipe(newCharm);
162163

163164
return newCharm.entityId;

typescript/packages/common-charm/src/storage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class StorageImpl implements Storage {
236236
this.cancel();
237237
}
238238

239-
// TODO: Should just be one again.
239+
// TODO(seefeld,gozala): Should just be one again.
240240
private _getStorageProviderForSpace(space: Space): StorageProvider {
241241
if (!space) throw new Error("No space set");
242242

@@ -608,7 +608,7 @@ class StorageImpl implements Storage {
608608

609609
// Write all storage jobs to storage, in parallel
610610
await Promise.all(
611-
Array.from(storageJobsBySpace.keys()).map(async (space) =>
611+
Array.from(storageJobsBySpace.keys()).map((space) =>
612612
this._getStorageProviderForSpace(space).send(
613613
storageJobsBySpace.get(space)!.map(({ entityId, value }) => ({
614614
entityId,

typescript/packages/common-charm/src/storage/base.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export interface StorageProvider {
1515
*/
1616
send<T = any>(
1717
batch: { entityId: EntityId; value: StorageValue<T> }[],
18-
): Promise<{ ok: {}; error?: undefined } | { ok?: undefined; error?: Error }>;
18+
): Promise<
19+
{ ok: object; error?: undefined } | { ok?: undefined; error?: Error }
20+
>;
1921

2022
/**
2123
* Sync a value from storage. Use `get()` to retrieve the value.
@@ -69,7 +71,9 @@ export abstract class BaseStorageProvider implements StorageProvider {
6971

7072
abstract send<T = any>(
7173
batch: { entityId: EntityId; value: StorageValue<T> }[],
72-
): Promise<{ ok: {}; error?: undefined } | { ok?: undefined; error: Error }>;
74+
): Promise<
75+
{ ok: object; error?: undefined } | { ok?: undefined; error: Error }
76+
>;
7377

7478
abstract sync(entityId: EntityId, expectedInStorage: boolean): Promise<void>;
7579

0 commit comments

Comments
 (0)