UNPKG

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