1 | /**
|
2 | * Metadata for deserializing an enum field on a contract/type
|
3 | */
|
4 | export interface ContractEnumMetadata {
|
5 | enumValues?: {
|
6 | [name: string]: number;
|
7 | };
|
8 | }
|
9 | export interface SerializationData {
|
10 | requestTypeMetadata?: ContractMetadata;
|
11 | responseTypeMetadata?: ContractMetadata;
|
12 | responseIsCollection: boolean;
|
13 | }
|
14 | /**
|
15 | * Metadata for deserializing a particular field on a contract/type
|
16 | */
|
17 | export interface ContractFieldMetadata {
|
18 | isArray?: boolean;
|
19 | isDate?: boolean;
|
20 | enumType?: ContractEnumMetadata;
|
21 | typeInfo?: ContractMetadata;
|
22 | isDictionary?: boolean;
|
23 | dictionaryKeyIsDate?: boolean;
|
24 | dictionaryValueIsDate?: boolean;
|
25 | dictionaryKeyEnumType?: ContractEnumMetadata;
|
26 | dictionaryValueEnumType?: ContractEnumMetadata;
|
27 | dictionaryValueTypeInfo?: ContractMetadata;
|
28 | dictionaryValueFieldInfo?: ContractFieldMetadata;
|
29 | }
|
30 | /**
|
31 | * Metadata required for deserializing a given type
|
32 | */
|
33 | export interface ContractMetadata {
|
34 | fields?: {
|
35 | [fieldName: string]: ContractFieldMetadata;
|
36 | };
|
37 | }
|
38 | export interface IWebApiArrayResult {
|
39 | count: number;
|
40 | value: any[];
|
41 | }
|
42 | /**
|
43 | * Module for handling serialization and deserialization of data contracts
|
44 | * (contracts sent from the server using the VSO default REST api serialization settings)
|
45 | */
|
46 | export declare module ContractSerializer {
|
47 | /**
|
48 | * Process a contract in its raw form (e.g. date fields are Dates, and Enums are numbers) and
|
49 | * return a pure JSON object that can be posted to REST endpoint.
|
50 | *
|
51 | * @param data The object to serialize
|
52 | * @param contractMetadata The type info/metadata for the contract type being serialized
|
53 | * @param preserveOriginal If true, don't modify the original object. False modifies the original object (the return value points to the data argument).
|
54 | */
|
55 | function serialize(data: any, contractMetadata: ContractMetadata, preserveOriginal: boolean): any;
|
56 | /**
|
57 | * Process a pure JSON object (e.g. that came from a REST call) and transform it into a JS object
|
58 | * where date strings are converted to Date objects and enum values are converted from strings into
|
59 | * their numerical value.
|
60 | *
|
61 | * @param data The object to deserialize
|
62 | * @param contractMetadata The type info/metadata for the contract type being deserialize
|
63 | * @param preserveOriginal If true, don't modify the original object. False modifies the original object (the return value points to the data argument).
|
64 | * @param unwrapWrappedCollections If true check for wrapped arrays (REST apis will not return arrays directly as the root result but will instead wrap them in a { values: [], count: 0 } object.
|
65 | */
|
66 | function deserialize(data: any, contractMetadata: ContractMetadata, preserveOriginal: boolean, unwrapWrappedCollections: boolean): any;
|
67 | }
|