From 1f0f11d9e1dd262c55809c03fe97ae5c4bd858d3 Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 21 Nov 2025 12:09:03 +0100 Subject: [PATCH] fix: wrap async calls in promise --- bindings/nodejs/index.d.ts | 6 +++--- bindings/nodejs/src/decision.rs | 2 +- bindings/nodejs/src/engine.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/nodejs/index.d.ts b/bindings/nodejs/index.d.ts index 591b8349..af3e13f8 100644 --- a/bindings/nodejs/index.d.ts +++ b/bindings/nodejs/index.d.ts @@ -3,7 +3,7 @@ export declare class ZenDecision { constructor() evaluate(context: any, opts?: ZenEvaluateOptions | undefined | null): Promise - safeEvaluate(context: any, opts?: ZenEvaluateOptions | undefined | null): { success: true, data: ZenEngineResponse } | { success: false; error: any; } + safeEvaluate(context: any, opts?: ZenEvaluateOptions | undefined | null): Promise<{ success: true, data: ZenEngineResponse } | { success: false; error: any; }> validate(): void } @@ -17,8 +17,8 @@ export declare class ZenEngine { evaluate(key: string, context: any, opts?: ZenEvaluateOptions | undefined | null): Promise createDecision(content: ZenDecisionContent | Buffer | object): ZenDecision getDecision(key: string): Promise - safeEvaluate(key: string, context: any, opts?: ZenEvaluateOptions | undefined | null): { success: true, data: ZenEngineResponse } | { success: false; error: any; } - safeGetDecision(key: string): { success: true, data: ZenDecision } | { success: false; error: any; } + safeEvaluate(key: string, context: any, opts?: ZenEvaluateOptions | undefined | null): Promise<{ success: true, data: ZenEngineResponse } | { success: false; error: any; }> + safeGetDecision(key: string): Promise<{ success: true, data: ZenDecision } | { success: false; error: any; }> dispose(): void } diff --git a/bindings/nodejs/src/decision.rs b/bindings/nodejs/src/decision.rs index 6ca3839c..7e16a198 100644 --- a/bindings/nodejs/src/decision.rs +++ b/bindings/nodejs/src/decision.rs @@ -47,7 +47,7 @@ impl ZenDecision { } #[napi( - ts_return_type = "{ success: true, data: ZenEngineResponse } | { success: false; error: any; }" + ts_return_type = "Promise<{ success: true, data: ZenEngineResponse } | { success: false; error: any; }>" )] pub async fn safe_evaluate( &self, diff --git a/bindings/nodejs/src/engine.rs b/bindings/nodejs/src/engine.rs index 4665ca8b..6e25cb1e 100644 --- a/bindings/nodejs/src/engine.rs +++ b/bindings/nodejs/src/engine.rs @@ -253,7 +253,7 @@ impl ZenEngine { } #[napi( - ts_return_type = "{ success: true, data: ZenEngineResponse } | { success: false; error: any; }" + ts_return_type = "Promise<{ success: true, data: ZenEngineResponse } | { success: false; error: any; }>" )] pub async fn safe_evaluate( &self, @@ -265,7 +265,7 @@ impl ZenEngine { } #[napi( - ts_return_type = "{ success: true, data: ZenDecision } | { success: false; error: any; }" + ts_return_type = "Promise<{ success: true, data: ZenDecision } | { success: false; error: any; }>" )] pub async fn safe_get_decision(&self, key: String) -> SafeResult { self.get_decision(key).await.into()