11import type { EntityId , Cancel } from "@commontools/runner" ;
22import { log } from "../storage.js" ;
33import { type StorageProvider , type StorageValue } from "./base.js" ;
4- import type { Entity , JSONValue , MemorySpace } from "@commontools/memory/interface" ;
4+ import type { Entity , JSONValue , MemorySpace , Protocol } from "@commontools/memory/interface" ;
55import * as Memory from "@commontools/memory/consumer" ;
6+ import * as Principal from "@commontools/memory/principal" ;
67import { assert } from "@commontools/memory/fact" ;
78import * as Changes from "@commontools/memory/changes" ;
89export * from "@commontools/memory/interface" ;
@@ -32,17 +33,22 @@ interface MemoryState<Space extends MemorySpace = MemorySpace> {
3233 * ed25519 key derived from the sha256 of the "common knowledge".
3334 */
3435const HOME = "did:key:z6Mko2qR9b8mbdPnaEKXvcYwdK7iDnRkh8mEcEP2719aCu6P" ;
36+
3537/**
3638 * ed25519 key derived from the sha256 of the "common operator".
3739 */
38- const AS = "did:key:z6Mkge3xkXc4ksLsf8CtRxunUxcX6dByT4QdWCVEHbUJ8YVn" ;
40+ const AS =
41+ Principal . ED25519Signer . fromString < "did:key:z6Mkge3xkXc4ksLsf8CtRxunUxcX6dByT4QdWCVEHbUJ8YVn" > (
42+ "MgCZHlm5ODrbwDGXGIgBhqp2HmKj3dcxxyaqkopec6vK7xO0BIHsZlqE1qjfTHd7TN9Xcw59xgzDElFlwH2OmKQOO0Gk=" ,
43+ ) ;
44+
3945export class RemoteStorageProvider implements StorageProvider {
4046 connection : WebSocket | null = null ;
4147 address : URL ;
4248 workspace : MemorySpace ;
4349 the : string ;
4450 state : Map < MemorySpace , MemoryState > = new Map ( ) ;
45- session : Memory . MemorySession ;
51+ session : Memory . MemorySession < MemorySpace > ;
4652
4753 /**
4854 * queue that holds commands that we read from the session, but could not
@@ -61,7 +67,7 @@ export class RemoteStorageProvider implements StorageProvider {
6167 the = "application/json" ,
6268 } : {
6369 address : URL ;
64- as ?: Memory . DID ;
70+ as ?: Memory . Signer ;
6571 space ?: MemorySpace ;
6672 the ?: string ;
6773 } ) {
@@ -377,7 +383,7 @@ export interface Subscriber {
377383class Query < Space extends MemorySpace > {
378384 reader : ReadableStreamDefaultReader ;
379385 constructor (
380- public query : Memory . QueryView < Space > ,
386+ public query : Memory . QueryView < Space , Protocol < Space > > ,
381387 public subscribers : Set < Subscriber > = new Set ( ) ,
382388 ) {
383389 this . reader = query . subscribe ( ) . getReader ( ) ;
0 commit comments