OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[OV JS] Add TS definition for AnyMap (#26711)
Alicja Miloszewska32aaa2fbd969
diff --git a/src/bindings/js/node/lib/addon.ts b/src/bindings/js/node/lib/addon.tsindex 060af2cfec9..24c9d780aa9 100644--- a/src/bindings/js/node/lib/addon.ts+++ b/src/bindings/js/node/lib/addon.ts@@ -21,6 +21,8 @@ type elementTypeString =| 'f32'| 'string';+type OVAny = string | number | boolean;+/*** Core represents an OpenVINO runtime Core entity.*@@ -48,7 +50,7 @@ interface Core {compileModel(model: Model,deviceName: string,- config?: { [propertyName: string]: string },+ config?: Record<string, OVAny>,): Promise<CompiledModel>;/*** Asynchronously reads a model and creates a compiled model@@ -67,7 +69,7 @@ interface Core {compileModel(modelPath: string,deviceName: string,- config?: { [propertyName: string]: string },+ config?: Record<string, OVAny>,): Promise<CompiledModel>;/*** A synchronous version of {@link Core.compileModel}.@@ -76,7 +78,7 @@ interface Core {compileModelSync(model: Model,deviceName: string,- config?: { [propertyName: string]: string },+ config?: Record<string, OVAny>,): CompiledModel;/*** A synchronous version of {@link Core.compileModel}.@@ -85,7 +87,7 @@ interface Core {compileModelSync(modelPath: string,deviceName: string,- config?: { [propertyName: string]: string },+ config?: Record<string, OVAny>,): CompiledModel;/*** It returns a list of available inference devices.@@ -101,7 +103,7 @@ interface Core {* It gets the properties dedicated to device behaviour.* @param propertyName A property name.*/- getProperty(propertyName: string): string | number | boolean;+ getProperty(propertyName: string): OVAny;/*** It gets the properties dedicated to device behaviour.@@ -111,7 +113,7 @@ interface Core {getProperty(deviceName: string,propertyName: string,- ): string | number | boolean;+ ): OVAny;/*** It returns information on the version of device plugins.* @param deviceName A device name to identify a plugin.@@ -135,7 +137,7 @@ interface Core {importModel(modelStream: Buffer,device: string,- config?: { [key: string]: string | number | boolean },+ config?: Record<string, OVAny>,): Promise<CompiledModel>;/*** A synchronous version of {@link Core.importModel}.@@ -144,7 +146,7 @@ interface Core {importModelSync(modelStream: Buffer,device: string,- config?: { [key: string]: string | number | boolean },+ config?: Record<string, OVAny>,): CompiledModel;/*** It reads models from the IR / ONNX / PDPD / TF and TFLite formats.@@ -197,16 +199,13 @@ interface Core {* It sets the properties.* @param properties An object with the property name - property value pairs.*/- setProperty(properties: { [key: string]: string | number | boolean }): void;+ setProperty(properties: Record<string, OVAny>): void;/*** It sets the properties for a device.* @param deviceName The name of a device.* @param properties An object with the property name - property value pairs.*/- setProperty(- deviceName: string,- properties: { [key: string]: string | number | boolean },- ): void;+ setProperty(deviceName: string, properties: Record<string, OVAny>): void;/*** It queries the device if it supports specified model with the specified* properties.@@ -218,8 +217,8 @@ interface Core {queryModel(model: Model,deviceName: string,- properties?: {[key: string]: string | number | boolean},- ): {[key: string]: string | number | boolean};+ properties?: Record<string, OVAny>,+ ): { [key: string]: string };}interface CoreConstructor {new (): Core;@@ -325,7 +324,7 @@ interface CompiledModel {* @param propertyName A string to get the property value.* @returns The property value.*/- getProperty(propertyName: string): string | number | boolean;+ getProperty(propertyName: string): OVAny;/*** It creates an inference request object used to infer the compiled model.* @return {InferRequest}@@ -380,9 +379,7 @@ interface CompiledModel {* @param property An object with the key-value pairs.* (property name, property value)*/- setProperty(properties: {- [propertyName: string]: string | number | boolean;- }): void;+ setProperty(properties: Record<string, OVAny>): void;}/**diff --git a/src/bindings/js/node/tests/unit/core.test.js b/src/bindings/js/node/tests/unit/core.test.jsindex 6cf431a38b5..f62adda9f90 100644--- a/src/bindings/js/node/tests/unit/core.test.js+++ b/src/bindings/js/node/tests/unit/core.test.js@@ -12,11 +12,11 @@ describe('ov.Core tests', () => {before(async () => {await isModelAvailable(testModels.testModelFP32);});-+beforeEach(() => {core = new ov.Core();});-+it('Core.setProperty()', () => {const tmpDir = '/tmp';@@ -83,29 +83,29 @@ describe('ov.Core tests', () => {it('Core.queryModel() with empty parameters should throw an error', () => {assert.throws(() => core.queryModel().then(),- /'queryModel' method called with incorrect parameters./- )+ /'queryModel' method called with incorrect parameters./,+ );});it('Core.queryModel() with less arguments should throw an error', () => {assert.throws(- () => core.queryModel("Unexpected Argument").then(),- /'queryModel' method called with incorrect parameters./- )+ () => core.queryModel('Unexpected Argument').then(),+ /'queryModel' method called with incorrect parameters./,+ );});it('Core.queryModel() with incorrect arguments should throw an error', () => {const model = core.readModelSync(getModelPath().xml);assert.throws(- () => core.queryModel(model, "arg1", "arg2").then(),- /'queryModel' method called with incorrect parameters./- )+ () => core.queryModel(model, 'arg1', 'arg2').then(),+ /'queryModel' method called with incorrect parameters./,+ );});it('Core.queryModel() should have device in the result values', () => {const model = core.readModelSync(getModelPath().xml);const device = 'CPU';- const query_model = core.queryModel(model, device);- assert(Object.values(query_model).includes(device));+ const queryModel = core.queryModel(model, device);+ assert(Object.values(queryModel).includes(device));});});