From 4ba8c4ca3dee8a0424ea773583f6f869b5c8403a Mon Sep 17 00:00:00 2001 From: grethy Date: Thu, 6 Nov 2025 10:48:02 +0100 Subject: [PATCH 1/2] Declarations - release 23.26.0 --- declarations/mle-encode-base64/package.json | 2 +- declarations/mle-js-bindings/package.json | 2 +- declarations/mle-js-encodings/package.json | 2 +- declarations/mle-js-fetch/package.json | 2 +- declarations/mle-js-oracledb/api.d.ts | 72 +++++++- .../mle-js-oracledb-common.d.ts | 5 +- declarations/mle-js-oracledb/package.json | 2 +- declarations/mle-js-plsql-ffi/package.json | 2 +- .../mle-js-plsqltypes/mle-js-plsqltypes.d.ts | 80 ++++++++- declarations/mle-js-plsqltypes/package.json | 2 +- declarations/mle-js/README.md | 5 - declarations/mle-js/mle-js.d.ts | 166 +++++++++++++++++- declarations/mle-js/package.json | 2 +- index.d.ts | 166 +++++++++++++++++- package.json | 2 +- test/mle-js-tests.ts | 15 ++ 16 files changed, 498 insertions(+), 29 deletions(-) diff --git a/declarations/mle-encode-base64/package.json b/declarations/mle-encode-base64/package.json index 83368ab..61fb2dc 100644 --- a/declarations/mle-encode-base64/package.json +++ b/declarations/mle-encode-base64/package.json @@ -3,7 +3,7 @@ "description": "MLE functions to work with base64 encoded data", "types": "mle-encode-base64.d.ts", "author": "Oracle", - "version": "23.9.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/declarations/mle-js-bindings/package.json b/declarations/mle-js-bindings/package.json index c61ab89..f81d490 100644 --- a/declarations/mle-js-bindings/package.json +++ b/declarations/mle-js-bindings/package.json @@ -3,7 +3,7 @@ "description": "MLE Bindings for Oracle Database DBMS_MLE", "types": "mle-js-bindings.d.ts", "author": "Oracle", - "version": "23.9.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/declarations/mle-js-encodings/package.json b/declarations/mle-js-encodings/package.json index d50c365..8be7642 100644 --- a/declarations/mle-js-encodings/package.json +++ b/declarations/mle-js-encodings/package.json @@ -3,7 +3,7 @@ "description": "MLE text encoding API", "types": "index.d.ts", "author": "Oracle", - "version": "23.9.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/declarations/mle-js-fetch/package.json b/declarations/mle-js-fetch/package.json index 495eea8..7a85781 100644 --- a/declarations/mle-js-fetch/package.json +++ b/declarations/mle-js-fetch/package.json @@ -3,7 +3,7 @@ "description": "MLE Fetch API polyfill", "types": "index.d.ts", "author": "Oracle", - "version": "23.9.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/declarations/mle-js-oracledb/api.d.ts b/declarations/mle-js-oracledb/api.d.ts index 56a208e..0183abe 100644 --- a/declarations/mle-js-oracledb/api.d.ts +++ b/declarations/mle-js-oracledb/api.d.ts @@ -1,5 +1,5 @@ /** -Copyright (c) 2019, 2024, Oracle and/or its affiliates. +Copyright (c) 2019, 2025, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 @@ -201,7 +201,7 @@ export interface IExecuteManyOptions { */ export interface IMetaData { /** - * The column name follows Oracle’s standard name-casing rules. It will commonly be uppercase + * The column name follows Oracle's standard name-casing rules. It will commonly be uppercase * since most applications create tables using unquoted, case-insensitive names. */ name: string; @@ -239,7 +239,7 @@ export interface IMetaData { */ nullable?: boolean; /** - * Name of the database type, such as “NUMBER” or “VARCHAR2”. + * Name of the database type, such as "NUMBER" or "VARCHAR2". */ dbTypeName?: string; /** @@ -254,6 +254,17 @@ export interface IMetaData { * @since Oracle 23.4 */ vectorFormat?: number; + /** + * Indicates if the column is known to contain a sparse vector. + * @since Oracle 23.26.0 + */ + isSparseVector?: boolean; + /** + * Indicates if the column is known to + * contain binary encoded OSON data. + * @since Oracle 23.26.0 + */ + isOson?: boolean; } /** * Interface for representing result sets as returned by {@link execute}(). @@ -650,7 +661,7 @@ export declare abstract class IDbObjectClass { readonly elementTypeClass?: IDbObjectClass; /** * When dbObject.isCollection is true, this will have the name of the - * element type, such as “VARCHAR2” or “NUMBER”. + * element type, such as "VARCHAR2" or "NUMBER". */ readonly elementTypeName?: string; /** @@ -1235,3 +1246,56 @@ export declare class Parameters { */ set fetchTypeHandler(value: FetchTypeHandler); } +/** + * Interface for representing a SparseVectors construction arguments. + * @since Oracle 23.26.0 + */ +export interface ISparseVectorConstructorArgs { + /** + * This property is a JavaScript array or a 32-bit unsigned integer + * (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of + * the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non- + * zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; +} +/** + * Interface for representing a SparseVector Class stores information about a sparse vector. + * @since Oracle 23.26.0 + */ +export declare abstract class ISparseVector { + /** + * This property is a JavaScript array or a 32-bit unsigned integer (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non-zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; + /** + * Constructs a SparseVector. + */ + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + /** + * Converts a sparse vector to a dense vector and returns a TypedArray of 8-bit signed integers, 32-bit floating-point numbers, + * or 64-bit floating-point numbers depending on the storage format of the sparse vector column's + * non-zero values in Oracle Database. + * + * This method is best used with sparse vectors read from Oracle Database. + */ + abstract dense(): Uint8Array | Float32Array | Float64Array; +} diff --git a/declarations/mle-js-oracledb/mle-js-oracledb-common.d.ts b/declarations/mle-js-oracledb/mle-js-oracledb-common.d.ts index 36a00b4..0037987 100644 --- a/declarations/mle-js-oracledb/mle-js-oracledb-common.d.ts +++ b/declarations/mle-js-oracledb/mle-js-oracledb-common.d.ts @@ -1,5 +1,5 @@ /** -Copyright (c) 2017, 2024, Oracle and/or its affiliates. +Copyright (c) 2017, 2025, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 @@ -37,6 +37,8 @@ SOFTWARE. */ import { Parameters, IConnection, IResultSet, OutFormatType, JsType, FetchTypeHandler } from './api'; import { ISodaCollection, ISodaDatabase, ISodaDocument, ISodaDocumentCursor, ISodaOperation } from './soda-api'; +import { SparseVector } from 'mle-js-plsqltypes'; +export { SparseVector } from 'mle-js-plsqltypes'; export declare class OracleDb { #private; OUT_FORMAT_ARRAY: number; @@ -128,6 +130,7 @@ export declare class OracleDb { OracleDb: typeof OracleDb; Connection: typeof IConnection; ResultSet: typeof IResultSet; + SparseVector: typeof SparseVector; /** * Construct a new OracleDb object for connecting and querying Oracle Database. * diff --git a/declarations/mle-js-oracledb/package.json b/declarations/mle-js-oracledb/package.json index e3ecfc2..85f29c5 100644 --- a/declarations/mle-js-oracledb/package.json +++ b/declarations/mle-js-oracledb/package.json @@ -3,7 +3,7 @@ "description": "MLE SQL Driver", "types": "index.d.ts", "author": "Oracle", - "version": "23.9.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/declarations/mle-js-plsql-ffi/package.json b/declarations/mle-js-plsql-ffi/package.json index dae1ed8..41712f6 100644 --- a/declarations/mle-js-plsql-ffi/package.json +++ b/declarations/mle-js-plsql-ffi/package.json @@ -3,7 +3,7 @@ "description": "MLE Foreign Function Interface (FFI): API for calling PL/SQL functionality directly", "types": "index.d.ts", "author": "Oracle", - "version": "23.9.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts b/declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts index 9f0a903..d21a043 100644 --- a/declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts +++ b/declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts @@ -1,5 +1,5 @@ /** -Copyright (c) 2019, 2024, Oracle and/or its affiliates. +/** The Universal Permissive License (UPL), Version 1.0 @@ -35,7 +35,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/** * Class which implements infix operators for Oracle Number * arithmetics: +, -, /, *, etc. * @@ -1230,4 +1229,81 @@ export declare class IOracleDate { export declare class JsonId extends Uint8Array { toJSON(): string; } +/** + * Interface for representing a SparseVectors construction arguments. + * @since Oracle 23.26.0 + */ +export interface ISparseVectorConstructorArgs { + /** + * This property is a JavaScript array or a 32-bit unsigned integer + * (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of + * the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non- + * zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; +} +/** + * Interface for representing a SparseVector Class stores information about a sparse vector. + * @since Oracle 23.26.0 + */ +export declare abstract class ISparseVector { + /** + * This property is a JavaScript array or a 32-bit unsigned integer (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non-zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; + /** + * Constructs a SparseVector. + */ + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + /** + * Converts a sparse vector to a dense vector and returns a TypedArray of 8-bit signed integers, 32-bit floating-point numbers, + * or 64-bit floating-point numbers depending on the storage format of the sparse vector column's + * non-zero values in Oracle Database. + * + * This method is best used with sparse vectors read from Oracle Database. + */ + abstract dense(): Uint8Array | Float32Array | Float64Array; +} +/** + * A SparseVector class stores information about a sparse vector. + * This class represents an object that accepts one of the following + * types in its constructor: typed array, JavaScript array, object, or string. + */ +export declare class SparseVector extends ISparseVector { + static MAX_UINT32: number; + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + private _validDenseArray; + private static _validateLengths; + private _updateProperties; + private _fromObject; + private _convertToTypedArrays; + private _fromString; + private _fromDense; + static create(sparseValue: any): any; + toJSON(): { + numDimensions: number; + indices: number[] | Uint32Array; + values: number[] | Uint8Array | Float32Array | Float64Array; + }; + private _createEmptyArray; + dense(): any; +} export {}; diff --git a/declarations/mle-js-plsqltypes/package.json b/declarations/mle-js-plsqltypes/package.json index 28bdb9c..62a33f1 100644 --- a/declarations/mle-js-plsqltypes/package.json +++ b/declarations/mle-js-plsqltypes/package.json @@ -3,7 +3,7 @@ "description": "MLE PL/SQL Types", "types": "mle-js-plsqltypes.d.ts", "author": "Oracle", - "version": "23.9.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/declarations/mle-js/README.md b/declarations/mle-js/README.md index 41e7959..7ed9f36 100644 --- a/declarations/mle-js/README.md +++ b/declarations/mle-js/README.md @@ -1,6 +1 @@ -Note that using this package is deprecated and that instead you should just install `@types/mle-js` like this: -```sh -npm install --saveDev "https://github.com/oracle-samples/mle-modules#main" -``` - Please consult the installation instructions and documentation on https://oracle-samples.github.io/mle-modules. diff --git a/declarations/mle-js/mle-js.d.ts b/declarations/mle-js/mle-js.d.ts index 9bba4ce..4e4a3f5 100644 --- a/declarations/mle-js/mle-js.d.ts +++ b/declarations/mle-js/mle-js.d.ts @@ -133,7 +133,6 @@ export function exportValue(name: string, value: any): void; */ declare namespace __mle_js_plsqltypes { - /** * Class which implements infix operators for Oracle Number * arithmetics: +, -, /, *, etc. @@ -1315,6 +1314,86 @@ export class IOracleDate { export class JsonId extends Uint8Array { toJSON(): string; } + +/** + * Interface for representing a SparseVectors construction arguments. + * @since Oracle 23.26.0 + */ +export interface ISparseVectorConstructorArgs { + /** + * This property is a JavaScript array or a 32-bit unsigned integer + * (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of + * the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non- + * zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; +} + +/** + * Interface for representing a SparseVector Class stores information about a sparse vector. + * @since Oracle 23.26.0 + */ +export abstract class ISparseVector { + /** + * This property is a JavaScript array or a 32-bit unsigned integer (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non-zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; + /** + * Constructs a SparseVector. + */ + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + /** + * Converts a sparse vector to a dense vector and returns a TypedArray of 8-bit signed integers, 32-bit floating-point numbers, + * or 64-bit floating-point numbers depending on the storage format of the sparse vector column's + * non-zero values in Oracle Database. + * + * This method is best used with sparse vectors read from Oracle Database. + */ + abstract dense(): Uint8Array | Float32Array | Float64Array; +} + +/** + * A SparseVector class stores information about a sparse vector. + * This class represents an object that accepts one of the following + * types in its constructor: typed array, JavaScript array, object, or string. + */ +export class SparseVector extends ISparseVector { + static MAX_UINT32: number; + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + private _validDenseArray; + private static _validateLengths; + private _updateProperties; + private _fromObject; + private _convertToTypedArrays; + private _fromString; + private _fromDense; + static create(sparseValue: any): any; + toJSON(): { + numDimensions: number; + indices: number[] | Uint32Array; + values: number[] | Uint8Array | Float32Array | Float64Array; + }; + private _createEmptyArray; + dense(): any; +} } declare module "mle-js-plsqltypes" { @@ -1371,6 +1450,12 @@ export const IOracleDate: __mle_js_plsqltypes.IOracleDate; type IOracleDate = __mle_js_plsqltypes.IOracleDate; export const JsonId: __mle_js_plsqltypes.JsonId; type JsonId = __mle_js_plsqltypes.JsonId; +export const ISparseVectorConstructorArgs: __mle_js_plsqltypes.ISparseVectorConstructorArgs; +type ISparseVectorConstructorArgs = __mle_js_plsqltypes.ISparseVectorConstructorArgs; +export const ISparseVector: __mle_js_plsqltypes.ISparseVector; +type ISparseVector = __mle_js_plsqltypes.ISparseVector; +export const SparseVector: __mle_js_plsqltypes.SparseVector; +type SparseVector = __mle_js_plsqltypes.SparseVector; } @@ -2019,7 +2104,7 @@ interface IExecuteManyOptions { */ interface IMetaData { /** - * The column name follows Oracle’s standard name-casing rules. It will commonly be uppercase + * The column name follows Oracle's standard name-casing rules. It will commonly be uppercase * since most applications create tables using unquoted, case-insensitive names. */ name: string; @@ -2057,7 +2142,7 @@ interface IMetaData { */ nullable?: boolean; /** - * Name of the database type, such as “NUMBER” or “VARCHAR2”. + * Name of the database type, such as "NUMBER" or "VARCHAR2". */ dbTypeName?: string; /** @@ -2072,6 +2157,17 @@ interface IMetaData { * @since Oracle 23.4 */ vectorFormat?: number; + /** + * Indicates if the column is known to contain a sparse vector. + * @since Oracle 23.26.0 + */ + isSparseVector?: boolean; + /** + * Indicates if the column is known to + * contain binary encoded OSON data. + * @since Oracle 23.26.0 + */ + isOson?: boolean; } /** @@ -2481,7 +2577,7 @@ abstract class IDbObjectClass { readonly elementTypeClass?: IDbObjectClass; /** * When dbObject.isCollection is true, this will have the name of the - * element type, such as “VARCHAR2” or “NUMBER”. + * element type, such as "VARCHAR2" or "NUMBER". */ readonly elementTypeName?: string; /** @@ -2789,6 +2885,61 @@ class Parameters { set fetchTypeHandler(value: FetchTypeHandler); } +/** + * Interface for representing a SparseVectors construction arguments. + * @since Oracle 23.26.0 + */ +interface ISparseVectorConstructorArgs { + /** + * This property is a JavaScript array or a 32-bit unsigned integer + * (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of + * the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non- + * zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; +} + +/** + * Interface for representing a SparseVector Class stores information about a sparse vector. + * @since Oracle 23.26.0 + */ +export abstract class ISparseVector { + /** + * This property is a JavaScript array or a 32-bit unsigned integer (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non-zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; + /** + * Constructs a SparseVector. + */ + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + /** + * Converts a sparse vector to a dense vector and returns a TypedArray of 8-bit signed integers, 32-bit floating-point numbers, + * or 64-bit floating-point numbers depending on the storage format of the sparse vector column's + * non-zero values in Oracle Database. + * + * This method is best used with sparse vectors read from Oracle Database. + */ + abstract dense(): Uint8Array | Float32Array | Float64Array; +} + export class OracleDb { #private; OUT_FORMAT_ARRAY: number; @@ -2880,6 +3031,7 @@ export class OracleDb { OracleDb: typeof OracleDb; Connection: typeof IConnection; ResultSet: typeof IResultSet; + SparseVector: typeof SparseVector; /** * Construct a new OracleDb object for connecting and querying Oracle Database. * @@ -3331,6 +3483,8 @@ const SODA_COLL_MAP_MODE = 5001; type Converter = __mle_js_oracledb.Converter; type FetchTypeHandler = __mle_js_oracledb.FetchTypeHandler; type Parameters = __mle_js_oracledb.Parameters; +type ISparseVectorConstructorArgs = __mle_js_oracledb.ISparseVectorConstructorArgs; +type ISparseVector = __mle_js_oracledb.ISparseVector; type OracleDb = __mle_js_oracledb.OracleDb; @@ -4256,3 +4410,7 @@ declare const plsffi: { resolveFunction: typeof __mle_js_plsql_ffi.resolveFunction; resolveProcedure: typeof __mle_js_plsql_ffi.resolveProcedure; }; + +/* @since Oracle 23.26.0 */ +declare const SparseVector: typeof __mle_js_plsqltypes.SparseVector; +type SparseVector = __mle_js_plsqltypes.SparseVector; diff --git a/declarations/mle-js/package.json b/declarations/mle-js/package.json index ed6ca8f..56c9ddd 100644 --- a/declarations/mle-js/package.json +++ b/declarations/mle-js/package.json @@ -3,7 +3,7 @@ "description": "Bundle of all declarations of pre-defined JavaScript modules that ship with Oracle Database", "types": "mle-js.d.ts", "author": "Oracle", - "version": "23.9.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/index.d.ts b/index.d.ts index 9bba4ce..4e4a3f5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -133,7 +133,6 @@ export function exportValue(name: string, value: any): void; */ declare namespace __mle_js_plsqltypes { - /** * Class which implements infix operators for Oracle Number * arithmetics: +, -, /, *, etc. @@ -1315,6 +1314,86 @@ export class IOracleDate { export class JsonId extends Uint8Array { toJSON(): string; } + +/** + * Interface for representing a SparseVectors construction arguments. + * @since Oracle 23.26.0 + */ +export interface ISparseVectorConstructorArgs { + /** + * This property is a JavaScript array or a 32-bit unsigned integer + * (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of + * the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non- + * zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; +} + +/** + * Interface for representing a SparseVector Class stores information about a sparse vector. + * @since Oracle 23.26.0 + */ +export abstract class ISparseVector { + /** + * This property is a JavaScript array or a 32-bit unsigned integer (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non-zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; + /** + * Constructs a SparseVector. + */ + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + /** + * Converts a sparse vector to a dense vector and returns a TypedArray of 8-bit signed integers, 32-bit floating-point numbers, + * or 64-bit floating-point numbers depending on the storage format of the sparse vector column's + * non-zero values in Oracle Database. + * + * This method is best used with sparse vectors read from Oracle Database. + */ + abstract dense(): Uint8Array | Float32Array | Float64Array; +} + +/** + * A SparseVector class stores information about a sparse vector. + * This class represents an object that accepts one of the following + * types in its constructor: typed array, JavaScript array, object, or string. + */ +export class SparseVector extends ISparseVector { + static MAX_UINT32: number; + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + private _validDenseArray; + private static _validateLengths; + private _updateProperties; + private _fromObject; + private _convertToTypedArrays; + private _fromString; + private _fromDense; + static create(sparseValue: any): any; + toJSON(): { + numDimensions: number; + indices: number[] | Uint32Array; + values: number[] | Uint8Array | Float32Array | Float64Array; + }; + private _createEmptyArray; + dense(): any; +} } declare module "mle-js-plsqltypes" { @@ -1371,6 +1450,12 @@ export const IOracleDate: __mle_js_plsqltypes.IOracleDate; type IOracleDate = __mle_js_plsqltypes.IOracleDate; export const JsonId: __mle_js_plsqltypes.JsonId; type JsonId = __mle_js_plsqltypes.JsonId; +export const ISparseVectorConstructorArgs: __mle_js_plsqltypes.ISparseVectorConstructorArgs; +type ISparseVectorConstructorArgs = __mle_js_plsqltypes.ISparseVectorConstructorArgs; +export const ISparseVector: __mle_js_plsqltypes.ISparseVector; +type ISparseVector = __mle_js_plsqltypes.ISparseVector; +export const SparseVector: __mle_js_plsqltypes.SparseVector; +type SparseVector = __mle_js_plsqltypes.SparseVector; } @@ -2019,7 +2104,7 @@ interface IExecuteManyOptions { */ interface IMetaData { /** - * The column name follows Oracle’s standard name-casing rules. It will commonly be uppercase + * The column name follows Oracle's standard name-casing rules. It will commonly be uppercase * since most applications create tables using unquoted, case-insensitive names. */ name: string; @@ -2057,7 +2142,7 @@ interface IMetaData { */ nullable?: boolean; /** - * Name of the database type, such as “NUMBER” or “VARCHAR2”. + * Name of the database type, such as "NUMBER" or "VARCHAR2". */ dbTypeName?: string; /** @@ -2072,6 +2157,17 @@ interface IMetaData { * @since Oracle 23.4 */ vectorFormat?: number; + /** + * Indicates if the column is known to contain a sparse vector. + * @since Oracle 23.26.0 + */ + isSparseVector?: boolean; + /** + * Indicates if the column is known to + * contain binary encoded OSON data. + * @since Oracle 23.26.0 + */ + isOson?: boolean; } /** @@ -2481,7 +2577,7 @@ abstract class IDbObjectClass { readonly elementTypeClass?: IDbObjectClass; /** * When dbObject.isCollection is true, this will have the name of the - * element type, such as “VARCHAR2” or “NUMBER”. + * element type, such as "VARCHAR2" or "NUMBER". */ readonly elementTypeName?: string; /** @@ -2789,6 +2885,61 @@ class Parameters { set fetchTypeHandler(value: FetchTypeHandler); } +/** + * Interface for representing a SparseVectors construction arguments. + * @since Oracle 23.26.0 + */ +interface ISparseVectorConstructorArgs { + /** + * This property is a JavaScript array or a 32-bit unsigned integer + * (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of + * the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non- + * zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; +} + +/** + * Interface for representing a SparseVector Class stores information about a sparse vector. + * @since Oracle 23.26.0 + */ +export abstract class ISparseVector { + /** + * This property is a JavaScript array or a 32-bit unsigned integer (Uint32Array) TypedArray + * that specifies the indices (zero-based) of non-zero values in the vector. + */ + indices: number[] | Uint32Array; + /** + * This property is an integer that specifies the number of dimensions of the vector. + */ + numDimensions: number; + /** + * This property is a JavaScript array or TypedArray that specifies the non-zero values stored in the vector. + */ + values: number[] | Uint8Array | Float32Array | Float64Array; + /** + * Constructs a SparseVector. + */ + constructor(input: Uint8Array | Float32Array | Float64Array | number[] | string | ISparseVectorConstructorArgs); + /** + * Converts a sparse vector to a dense vector and returns a TypedArray of 8-bit signed integers, 32-bit floating-point numbers, + * or 64-bit floating-point numbers depending on the storage format of the sparse vector column's + * non-zero values in Oracle Database. + * + * This method is best used with sparse vectors read from Oracle Database. + */ + abstract dense(): Uint8Array | Float32Array | Float64Array; +} + export class OracleDb { #private; OUT_FORMAT_ARRAY: number; @@ -2880,6 +3031,7 @@ export class OracleDb { OracleDb: typeof OracleDb; Connection: typeof IConnection; ResultSet: typeof IResultSet; + SparseVector: typeof SparseVector; /** * Construct a new OracleDb object for connecting and querying Oracle Database. * @@ -3331,6 +3483,8 @@ const SODA_COLL_MAP_MODE = 5001; type Converter = __mle_js_oracledb.Converter; type FetchTypeHandler = __mle_js_oracledb.FetchTypeHandler; type Parameters = __mle_js_oracledb.Parameters; +type ISparseVectorConstructorArgs = __mle_js_oracledb.ISparseVectorConstructorArgs; +type ISparseVector = __mle_js_oracledb.ISparseVector; type OracleDb = __mle_js_oracledb.OracleDb; @@ -4256,3 +4410,7 @@ declare const plsffi: { resolveFunction: typeof __mle_js_plsql_ffi.resolveFunction; resolveProcedure: typeof __mle_js_plsql_ffi.resolveProcedure; }; + +/* @since Oracle 23.26.0 */ +declare const SparseVector: typeof __mle_js_plsqltypes.SparseVector; +type SparseVector = __mle_js_plsqltypes.SparseVector; diff --git a/package.json b/package.json index d02382d..3ff64f9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "TypeScript definitions for Bundle of all declarations of pre-defined JavaScript modules that ship with Oracle Database", "types": "index.d.ts", "author": "Oracle", - "version": "23.8.0", + "version": "23.26.0", "license": "UPL-1.0", "homepage": "https://oracle-samples.github.io/mle-modules", "repository": { diff --git a/test/mle-js-tests.ts b/test/mle-js-tests.ts index 8f2d828..7b2fe47 100644 --- a/test/mle-js-tests.ts +++ b/test/mle-js-tests.ts @@ -341,6 +341,20 @@ function testFetchTypeHandler() { }); } +function testSparseVector() { + const v1 = new oracledb.SparseVector({ + values: new Float64Array([10, 20]), + indices: [0, 6], + numDimensions: 20 + }); + const v2 = new SparseVector({ + values: new Float64Array([10, 20]), + indices: [0, 6], + numDimensions: 20 + }); + return JSON.stringify(v1.toJSON()) + JSON.stringify(v2.toJSON()); +} + async function mainTest() { oracleDBTest(); sessionTest(); @@ -362,6 +376,7 @@ async function mainTest() { testBindingsDoc(); testSqlDriverDocs(); testFetchTypeHandler(); + testSparseVector(); } mainTest(); From 15099a3d38d34d61fdefeb0d7b9b4a8dd07e035d Mon Sep 17 00:00:00 2001 From: grethy Date: Mon, 10 Nov 2025 09:50:19 +0100 Subject: [PATCH 2/2] Fix header --- declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts b/declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts index d21a043..cc7adf5 100644 --- a/declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts +++ b/declarations/mle-js-plsqltypes/mle-js-plsqltypes.d.ts @@ -1,5 +1,6 @@ /** -/** + +Copyright (c) 2019, 2025, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 @@ -35,6 +36,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +/** * Class which implements infix operators for Oracle Number * arithmetics: +, -, /, *, etc. *