import Null from './data-types/null'; import TinyInt from './data-types/tinyint'; import Bit from './data-types/bit'; import SmallInt from './data-types/smallint'; import Int from './data-types/int'; import SmallDateTime from './data-types/smalldatetime'; import Real from './data-types/real'; import Money from './data-types/money'; import DateTime from './data-types/datetime'; import Float from './data-types/float'; import Decimal from './data-types/decimal'; import Numeric from './data-types/numeric'; import SmallMoney from './data-types/smallmoney'; import BigInt from './data-types/bigint'; import Image from './data-types/image'; import Text from './data-types/text'; import UniqueIdentifier from './data-types/uniqueidentifier'; import IntN from './data-types/intn'; import NText from './data-types/ntext'; import BitN from './data-types/bitn'; import DecimalN from './data-types/decimaln'; import NumericN from './data-types/numericn'; import FloatN from './data-types/floatn'; import MoneyN from './data-types/moneyn'; import DateTimeN from './data-types/datetimen'; import VarBinary from './data-types/varbinary'; import VarChar from './data-types/varchar'; import Binary from './data-types/binary'; import Char from './data-types/char'; import NVarChar from './data-types/nvarchar'; import NChar from './data-types/nchar'; import Xml from './data-types/xml'; import Time from './data-types/time'; import Date from './data-types/date'; import DateTime2 from './data-types/datetime2'; import DateTimeOffset from './data-types/datetimeoffset'; import UDT from './data-types/udt'; import TVP from './data-types/tvp'; import Variant from './data-types/sql-variant'; import { type CryptoMetadata } from './always-encrypted/types'; import { type InternalConnectionOptions } from './connection'; import { Collation } from './collation'; import WritableTrackingBuffer from './tracking-buffer/writable-tracking-buffer'; export interface Parameter { type: DataType; name: string; value: unknown; output: boolean; length?: number | undefined; precision?: number | undefined; scale?: number | undefined; nullable?: boolean | undefined; forceEncrypt?: boolean | undefined; cryptoMetadata?: CryptoMetadata | undefined; encryptedVal?: Buffer | undefined; } export interface ParameterData { length?: number | undefined; scale?: number | undefined; precision?: number | undefined; collation?: Collation | undefined; value: T; } export interface DataType { id: number; type: string; name: string; declaration(parameter: Parameter): string; validate(value: any, collation: Collation | undefined, options?: InternalConnectionOptions): any; hasTableName?: boolean; resolveLength?: (parameter: Parameter) => number; resolvePrecision?: (parameter: Parameter) => number; resolveScale?: (parameter: Parameter) => number; /** * Validates the parameter's value and resolves its declaration facts * (length, precision, scale, collation) into a single struct that all * serialization is derived from. */ resolve?(parameter: Parameter, collation: Collation | undefined, options: InternalConnectionOptions): ParameterData; /** * Writes the TYPE_INFO of a resolved parameter. */ writeTypeInfo(buffer: WritableTrackingBuffer, parameter: ParameterData, options: InternalConnectionOptions): void; /** * Writes the value of a resolved parameter (length prefix and data). * * A value that is fully in memory is written before this returns. A value * that is read from a source while the request is written (an async * iterable, accepted by the `max` types and by a TVP's rows) returns the * rest of the write instead: an async iterable that yields whenever * `buffer` holds a chunk's worth (`WritableTrackingBuffer.CHUNK_SIZE`) or * more, so that the caller can hand those bytes on before the rest of the * value is read. Nothing of that rest runs before its first `next()`. */ writeValue(buffer: WritableTrackingBuffer, parameter: ParameterData, options: InternalConnectionOptions): void | AsyncIterable; } /** * A parameter whose value has been validated and whose declaration facts * have been resolved: everything serialization needs. */ export interface ResolvedParameter { name: string; output: boolean; type: DataType; data: ParameterData; } /** * Validates a parameter's value and resolves its declaration facts. This is * the single place where a parameter's length, precision, scale and * collation are determined. */ export declare function resolveParameter(parameter: Parameter, collation: Collation | undefined, options: InternalConnectionOptions): ResolvedParameter; /** * Drives the rest of a write returned by `writeValue`, yielding at each of * its yields. An error the rest throws is passed through `wrap` (e.g. to * name the parameter it belongs to); an error thrown into this generator by * its consumer keeps its identity, and a consumer that stops early closes * the rest, and with it the value's source, as `for await` would. */ export declare function writeRest(rest: AsyncIterable, wrap: (error: unknown) => Error): AsyncGenerator; export declare const TYPE: { [Null.id]: DataType; [TinyInt.id]: DataType; [Bit.id]: DataType; [SmallInt.id]: DataType; [Int.id]: DataType; [SmallDateTime.id]: DataType; [Real.id]: DataType; [Money.id]: DataType; [DateTime.id]: DataType; [Float.id]: DataType; [Decimal.id]: DataType & { resolvePrecision: NonNullable; resolveScale: NonNullable; }; [Numeric.id]: DataType & { resolveScale: NonNullable; resolvePrecision: NonNullable; }; [SmallMoney.id]: DataType; [BigInt.id]: DataType; [Image.id]: DataType; [Text.id]: DataType; [UniqueIdentifier.id]: DataType; [IntN.id]: DataType; [NText.id]: DataType; [BitN.id]: DataType; [DecimalN.id]: DataType; [NumericN.id]: DataType; [FloatN.id]: DataType; [MoneyN.id]: DataType; [DateTimeN.id]: DataType; [VarBinary.id]: { maximumLength: number; } & DataType; [VarChar.id]: { maximumLength: number; } & DataType; [Binary.id]: { maximumLength: number; } & DataType; [Char.id]: { maximumLength: number; } & DataType; [NVarChar.id]: { maximumLength: number; } & DataType; [NChar.id]: DataType & { maximumLength: number; }; [Xml.id]: DataType; [Time.id]: DataType; [Date.id]: DataType; [DateTime2.id]: DataType & { resolveScale: NonNullable; }; [DateTimeOffset.id]: DataType & { resolveScale: NonNullable; }; [UDT.id]: DataType; [TVP.id]: DataType; [Variant.id]: DataType; }; /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
TypeConstantJavaScriptResult setParameter
Exact numerics
bit{@link TYPES.Bit}boolean✓✓
tinyint{@link TYPES.TinyInt}number✓✓
smallint{@link TYPES.SmallInt}number✓✓
int{@link TYPES.Int}number✓✓
bigint1{@link TYPES.BigInt}string✓✓
numeric2{@link TYPES.Numeric}number✓✓
decimal2{@link TYPES.Decimal}number✓✓
smallmoney{@link TYPES.SmallMoney}number✓✓
money{@link TYPES.Money}number✓✓
Approximate numerics
float{@link TYPES.Float}number✓✓
real{@link TYPES.Real}number✓✓
Date and Time
smalldatetime{@link TYPES.SmallDateTime}Date✓✓
datetime{@link TYPES.DateTime}Date✓✓
datetime2{@link TYPES.DateTime2}Date✓✓
datetimeoffset{@link TYPES.DateTimeOffset}Date✓✓
time{@link TYPES.Time}Date✓✓
date{@link TYPES.Date}Date✓✓
Character Strings
char{@link TYPES.Char}string✓✓
varchar3{@link TYPES.VarChar}string✓✓
text{@link TYPES.Text}string✓✓
Unicode Strings
nchar{@link TYPES.NChar}string✓✓
nvarchar3{@link TYPES.NVarChar}string✓✓
ntext{@link TYPES.NText}string✓-
Binary Strings4
binary{@link TYPES.Binary}Buffer✓✓
varbinary{@link TYPES.VarBinary}Buffer✓✓
image{@link TYPES.Image}Buffer✓✓
Other Data Types
TVP{@link TYPES.TVP}Object-✓
UDT{@link TYPES.UDT}Buffer✓-
uniqueidentifier4{@link TYPES.UniqueIdentifier}string✓✓
variant{@link TYPES.Variant}any✓-
xml{@link TYPES.Xml}string✓-
* *
    *
  1. *

    BigInt

    *

    * Values are returned as a string. This is because values can exceed 53 bits of significant data, which is greater than a * Javascript number type can represent as an integer. *

    *
  2. *
  3. *

    Numerical, Decimal

    *

    * For input parameters, default precision is 18 and default scale is 0. Maximum supported precision is 19. *

    *
  4. *
  5. *

    VarChar, NVarChar

    *

    * varchar(max) and nvarchar(max) are also supported. *

    *
  6. *
  7. *

    UniqueIdentifier

    *

    * Values are returned as a 16 byte hexadecimal string. *

    *

    * Note that the order of bytes is not the same as the character representation. See * Using uniqueidentifier Data * for an example of the different ordering of bytes. *

    *
  8. *
*/ export declare const TYPES: { TinyInt: DataType; Bit: DataType; SmallInt: DataType; Int: DataType; SmallDateTime: DataType; Real: DataType; Money: DataType; DateTime: DataType; Float: DataType; Decimal: DataType & { resolvePrecision: NonNullable; resolveScale: NonNullable; }; Numeric: DataType & { resolveScale: NonNullable; resolvePrecision: NonNullable; }; SmallMoney: DataType; BigInt: DataType; Image: DataType; Text: DataType; UniqueIdentifier: DataType; NText: DataType; VarBinary: { maximumLength: number; } & DataType; VarChar: { maximumLength: number; } & DataType; Binary: { maximumLength: number; } & DataType; Char: { maximumLength: number; } & DataType; NVarChar: { maximumLength: number; } & DataType; NChar: DataType & { maximumLength: number; }; Xml: DataType; Time: DataType; Date: DataType; DateTime2: DataType & { resolveScale: NonNullable; }; DateTimeOffset: DataType & { resolveScale: NonNullable; }; UDT: DataType; TVP: DataType; Variant: DataType; }; export declare const typeByName: { TinyInt: DataType; Bit: DataType; SmallInt: DataType; Int: DataType; SmallDateTime: DataType; Real: DataType; Money: DataType; DateTime: DataType; Float: DataType; Decimal: DataType & { resolvePrecision: NonNullable; resolveScale: NonNullable; }; Numeric: DataType & { resolveScale: NonNullable; resolvePrecision: NonNullable; }; SmallMoney: DataType; BigInt: DataType; Image: DataType; Text: DataType; UniqueIdentifier: DataType; NText: DataType; VarBinary: { maximumLength: number; } & DataType; VarChar: { maximumLength: number; } & DataType; Binary: { maximumLength: number; } & DataType; Char: { maximumLength: number; } & DataType; NVarChar: { maximumLength: number; } & DataType; NChar: DataType & { maximumLength: number; }; Xml: DataType; Time: DataType; Date: DataType; DateTime2: DataType & { resolveScale: NonNullable; }; DateTimeOffset: DataType & { resolveScale: NonNullable; }; UDT: DataType; TVP: DataType; Variant: DataType; };