diff --git a/package.json b/package.json index b19e846..0fd7b97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ticketbridge/hyper-durable", - "version": "0.1.14", + "version": "0.1.15", "description": "Object-like access to Durable Object properties and methods", "repository": { "type": "git", diff --git a/src/HyperNamespaceProxy.ts b/src/HyperNamespaceProxy.ts index 9d282be..2069031 100644 --- a/src/HyperNamespaceProxy.ts +++ b/src/HyperNamespaceProxy.ts @@ -3,7 +3,7 @@ import { HyperError } from './HyperError'; export class HyperNamespaceProxy, Env> implements DurableObjectNamespace { namespace: DurableObjectNamespace; - ref: DO; + ref: new (state: DurableObjectState, env: Env) => DO; newUniqueId: (_options?: DurableObjectNamespaceNewUniqueIdOptions) => DurableObjectId; idFromName: (name: string) => DurableObjectId; @@ -14,9 +14,8 @@ export class HyperNamespaceProxy, Env> impleme ref: new (state: DurableObjectState, env: Env) => DO ) { this.namespace = namespace; - // Create a reference of the DO to check for methods / properties - // @ts-ignore - this.ref = new ref({}, {}); + // Reference of the DO to check for methods / properties + this.ref = ref; this.newUniqueId = namespace.newUniqueId; this.idFromName = namespace.idFromName; @@ -88,7 +87,7 @@ export class HyperNamespaceProxy, Env> impleme // Short circuit for fetch to maintain manual access if (key === 'fetch') return hyperStub.fetch.bind(hyperStub); - if (typeof this.ref[key] === 'function') { + if (typeof this.ref.prototype[key] === 'function') { // Anonymous function to pass args return function (...args: any[]) { const request = createHyperRequest('call', key, { args }); diff --git a/src/index.d.ts b/src/index.d.ts index 0f483ca..583f154 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -35,7 +35,7 @@ export type PromisedGetStub, Env> = { } export type SetStub, Env> = { - [Prop in keyof DO as DO[Prop] extends Function ? never : `set${Capitalize}`]?: + [Prop in keyof DO as DO[Prop] extends Function ? never : `set${Capitalize}`]: (newValue: DO[Prop]) => Promise }