UNPKG

1.62 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Collation } from './collation';
3import Parser, { type ParserOptions } from './token/stream-parser';
4import { type DataType } from './data-type';
5import { type CryptoMetadata } from './always-encrypted/types';
6import { Result } from './token/helpers';
7interface XmlSchema {
8 dbname: string;
9 owningSchema: string;
10 xmlSchemaCollection: string;
11}
12interface UdtInfo {
13 maxByteSize: number;
14 dbname: string;
15 owningSchema: string;
16 typeName: string;
17 assemblyName: string;
18}
19export type BaseMetadata = {
20 userType: number;
21 flags: number;
22 /**
23 * The column's type, such as VarChar, Int or Binary.
24 */
25 type: DataType;
26 collation: Collation | undefined;
27 /**
28 * The precision. Only applicable to numeric and decimal.
29 */
30 precision: number | undefined;
31 /**
32 * The scale. Only applicable to numeric, decimal, time, datetime2 and datetimeoffset.
33 */
34 scale: number | undefined;
35 /**
36 * The length, for char, varchar, nvarchar and varbinary.
37 */
38 dataLength: number | undefined;
39 schema: XmlSchema | undefined;
40 udtInfo: UdtInfo | undefined;
41};
42export type Metadata = {
43 cryptoMetadata?: CryptoMetadata;
44} & BaseMetadata;
45declare function readCollation(buf: Buffer, offset: number): Result<Collation>;
46declare function readMetadata(buf: Buffer, offset: number, options: ParserOptions): Result<Metadata>;
47declare function metadataParse(parser: Parser, options: ParserOptions, callback: (metadata: Metadata) => void): void;
48export default metadataParse;
49export { readCollation, readMetadata };