diff --git a/src/bindings/js/node/include/core_wrap.hpp b/src/bindings/js/node/include/core_wrap.hpp index 29149aaf157ea8..556857ea362311 100644 --- a/src/bindings/js/node/include/core_wrap.hpp +++ b/src/bindings/js/node/include/core_wrap.hpp @@ -68,6 +68,8 @@ class CoreWrap : public Napi::ObjectWrap { Napi::Value set_property(const Napi::CallbackInfo& info); Napi::Value get_property(const Napi::CallbackInfo& info); + Napi::Value query_model(const Napi::CallbackInfo& info); + void add_extension(const Napi::CallbackInfo& info); protected: Napi::Value compile_model_sync(const Napi::CallbackInfo& info, diff --git a/src/bindings/js/node/lib/addon.ts b/src/bindings/js/node/lib/addon.ts index 9ea694c154a641..681878f9545b4b 100644 --- a/src/bindings/js/node/lib/addon.ts +++ b/src/bindings/js/node/lib/addon.ts @@ -205,6 +205,13 @@ interface Core { deviceName: string, properties: { [key: string]: string | number | boolean }, ): void; + /** + * It queries the model passed for the requested property. + * @param model The passed model to query the property. + * @param deviceName The name of a device. + * @param properties An object with the property name - property value pairs. + */ + queryModel(model: Model, deviceName: string, properties?: {[key: string]: string | number | boolean}): {[key: string]: string | number | boolean}; } interface CoreConstructor { new(): Core; diff --git a/src/bindings/js/node/src/core_wrap.cpp b/src/bindings/js/node/src/core_wrap.cpp index 20422b7d683d3d..32c8a18f26ea11 100644 --- a/src/bindings/js/node/src/core_wrap.cpp +++ b/src/bindings/js/node/src/core_wrap.cpp @@ -57,6 +57,7 @@ Napi::Function CoreWrap::get_class(Napi::Env env) { InstanceMethod("getVersions", &CoreWrap::get_versions), InstanceMethod("setProperty", &CoreWrap::set_property), InstanceMethod("getProperty", &CoreWrap::get_property), + InstanceMethod("queryModel", &CoreWrap::query_model), InstanceMethod("addExtension", &CoreWrap::add_extension)}); } @@ -463,3 +464,29 @@ void CoreWrap::add_extension(const Napi::CallbackInfo& info) { reportError(info.Env(), err.what()); } } + +Napi::Value CoreWrap::query_model(const Napi::CallbackInfo& info) { + std::vector allowed_signatures; + try { + if (ov::js::validate(info, allowed_signatures) || + ov::js::validate(info, allowed_signatures)) { + ov::AnyMap properties; + auto model = Napi::ObjectWrap::Unwrap(info[0].ToObject())->get_model(); + auto device_name = info[1].ToString(); + if (info.Length() == 3) { + properties = to_anyMap(info.Env(), info[2]); + } + auto query_result = _core.query_model(model, device_name, properties); + Napi::Object result = Napi::Object::New(info.Env()); + for (const auto& elem: query_result) { + result.Set(elem.first, elem.second); + } + return result; + } else { + OPENVINO_THROW("'queryModel'", ov::js::get_parameters_error_msg(info, allowed_signatures)); + } + } catch (std::exception& err) { + reportError(info.Env(), err.what()); + return info.Env().Undefined(); + } +}