export interface Services { lockService : LockService ; kvService : KVService ; messageService : MessageService ; userService : UserService ; } export type LockService = ( ) => LockStore ; export type KVService = < T > ( ) => KVStore < T > ; export type MessageService = < T > ( ) => MessageBus < T > ; export type UserService = ( ) => UserStore ; export class LockError extends Error { status = "LockError" ; retryable = true ; } export class UnimplementedError extends Error { status = "UnimplementedError" ; retryable = false ; } export interface KVStore < T > { put ( key , val ) : Promise < void > ; get ( key ) : Promise < T | undefined > ; del ( key ) : Promise < void > ; list ( prefix ) : Promise < T [ ] > ; } export interface LockStore { lock ( key , handler ) : Promise < void > ; } export interface MessageBus < T > { subscribe ( topic , user ) : Promise < string | undefined > ; poll ( topic , user ) : Promise < void > ; publish ( topic , message ) : Promise < void > ; } export interface User { id : string ; username : string ; email : string ; createdAt ? : string ; } export interface UserStore { update ( user ) : Promise < User > ; delete ( id ) : Promise < void > ; }