Skip to content

Commit 793ec9c

Browse files
changing type definitions, adding more generic types
1 parent c82a6c0 commit 793ec9c

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

lib/dynamics-web-api-callbacks.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,7 @@ function DynamicsWebApi(config) {
783783
}
784784

785785
//add page number and paging cookie to fetch xml
786-
if (replacementString)
787-
fetchXml = fetchXml.replace(/^(<fetch)/, replacementString);
786+
if (replacementString) fetchXml = fetchXml.replace(/^(<fetch)/, replacementString);
788787
}
789788

790789
var request = {

lib/dynamics-web-api.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,7 @@ function DynamicsWebApi(config) {
771771
}
772772

773773
//add page number and paging cookie to fetch xml
774-
if (replacementString)
775-
fetchXml = fetchXml.replace(/^(<fetch)/, replacementString);
774+
if (replacementString) fetchXml = fetchXml.replace(/^(<fetch)/, replacementString);
776775
}
777776

778777
var request = {

types/dynamics-web-api-callbacks.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ declare class DynamicsWebApi {
4141
*});
4242
*/
4343
createRequest<T = any>(
44-
request: DynamicsWebApi.CreateRequest,
44+
request: DynamicsWebApi.CreateRequest<T>,
4545
successCallback?: (result: T) => void,
4646
errorCallback?: (error: DynamicsWebApi.RequestError) => void
4747
): void;
@@ -67,7 +67,7 @@ declare class DynamicsWebApi {
6767
*});
6868
*/
6969
create<T = any>(
70-
object: Object,
70+
object: T,
7171
collection: string,
7272
successCallback?: (result: T) => void,
7373
errorCallback?: (error: DynamicsWebApi.RequestError) => void,
@@ -82,7 +82,7 @@ declare class DynamicsWebApi {
8282
* @param errorCallback - The function that will be passed through and be called by a failed response.
8383
*/
8484
updateRequest<T = any>(
85-
request: DynamicsWebApi.UpdateRequest,
85+
request: DynamicsWebApi.UpdateRequest<T>,
8686
successCallback?: (result: T) => void,
8787
errorCallback?: (error: DynamicsWebApi.RequestError) => void
8888
): void;
@@ -100,7 +100,7 @@ declare class DynamicsWebApi {
100100
update<T = any>(
101101
key: string,
102102
collection: string,
103-
object: Object,
103+
object: T,
104104
successCallback?: (result: T) => void,
105105
errorCallback?: (error: DynamicsWebApi.RequestError) => void,
106106
prefer?: string | string[],
@@ -120,7 +120,7 @@ declare class DynamicsWebApi {
120120
updateSingleProperty(
121121
key: string,
122122
collection: string,
123-
keyValuePair: Object,
123+
keyValuePair: { [key: string]: any },
124124
successCallback?: Function,
125125
errorCallback?: (error: DynamicsWebApi.RequestError) => void,
126126
prefer?: string | string[],
@@ -188,7 +188,7 @@ declare class DynamicsWebApi {
188188
* @param errorCallback - The function that will be passed through and be called by a failed response.
189189
*/
190190
upsertRequest<T = any>(
191-
request: DynamicsWebApi.UpsertRequest,
191+
request: DynamicsWebApi.UpsertRequest<T>,
192192
successCallback?: (result: T) => void,
193193
errorCallback?: (error: DynamicsWebApi.RequestError) => void
194194
): void;
@@ -206,7 +206,7 @@ declare class DynamicsWebApi {
206206
upsert<T = any>(
207207
key: string,
208208
collection: string,
209-
object: Object,
209+
object: T,
210210
successCallback?: (result: T) => void,
211211
errorCallback?: (error: DynamicsWebApi.RequestError) => void,
212212
prefer?: string | string[],

types/dynamics-web-api.d.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ declare class DynamicsWebApi {
99
*/
1010
constructor(config?: DynamicsWebApi.Config);
1111
/**
12-
* Sets DynamicsWebApi configuration parameters.
13-
*
14-
* @param config - configuration object
15-
* @example
16-
dynamicsWebApi.setConfig({ webApiVersion: '9.1' });
17-
*/
12+
* Sets DynamicsWebApi configuration parameters.
13+
*
14+
* @param config - configuration object
15+
* @example
16+
dynamicsWebApi.setConfig({ webApiVersion: '9.1' });
17+
*/
1818
setConfig(config: DynamicsWebApi.Config): void;
1919
/**
2020
* Sends an asynchronous request to create a new record.
@@ -38,7 +38,7 @@ declare class DynamicsWebApi {
3838
*}.catch(function (error) {
3939
*});
4040
*/
41-
createRequest<T = any>(request: DynamicsWebApi.CreateRequest): Promise<T>;
41+
createRequest<T = any>(request: DynamicsWebApi.CreateRequest<T>): Promise<T>;
4242
/**
4343
* Sends an asynchronous request to create a new record.
4444
*
@@ -58,13 +58,13 @@ declare class DynamicsWebApi {
5858
*}.catch(function (error) {
5959
*});
6060
*/
61-
create<T = any>(object: Object, collection: string, prefer?: string | string[], select?: string[]): Promise<T>;
61+
create<T = any>(object: T, collection: string, prefer?: string | string[], select?: string[]): Promise<T>;
6262
/**
6363
* Sends an asynchronous request to update a record.
6464
*
6565
* @param request - An object that represents all possible options for a current request.
6666
*/
67-
updateRequest<T = any>(request: DynamicsWebApi.UpdateRequest): Promise<T>;
67+
updateRequest<T = any>(request: DynamicsWebApi.UpdateRequest<T>): Promise<T>;
6868
/**
6969
* Sends an asynchronous request to update a record.
7070
*
@@ -74,7 +74,7 @@ declare class DynamicsWebApi {
7474
* @param prefer - If set to "return=representation" the function will return an updated object
7575
* @param select - An Array representing the $select Query Option to control which attributes will be returned.
7676
*/
77-
update<T = any>(key: string, collection: string, object: Object, prefer?: string | string[], select?: string[]): Promise<T>;
77+
update<T = any>(key: string, collection: string, object: T, prefer?: string | string[], select?: string[]): Promise<T>;
7878
/**
7979
* Sends an asynchronous request to update a single value in the record.
8080
*
@@ -84,7 +84,13 @@ declare class DynamicsWebApi {
8484
* @param prefer - If set to "return=representation" the function will return an updated object
8585
* @param select - An Array representing the $select Query Option to control which attributes will be returned.
8686
*/
87-
updateSingleProperty<T = any>(key: string, collection: string, keyValuePair: Object, prefer?: string | string[], select?: string[]): Promise<T>;
87+
updateSingleProperty<T = any>(
88+
key: string,
89+
collection: string,
90+
keyValuePair: { [key: string]: any },
91+
prefer?: string | string[],
92+
select?: string[]
93+
): Promise<T>;
8894
/**
8995
* Sends an asynchronous request to delete a record.
9096
*
@@ -119,7 +125,7 @@ declare class DynamicsWebApi {
119125
*
120126
* @param request - An object that represents all possible options for a current request.
121127
*/
122-
upsertRequest<T = any>(request: DynamicsWebApi.UpsertRequest): Promise<T>;
128+
upsertRequest<T = any>(request: DynamicsWebApi.UpsertRequest<T>): Promise<T>;
123129
/**
124130
* Sends an asynchronous request to upsert a record.
125131
*
@@ -129,7 +135,7 @@ declare class DynamicsWebApi {
129135
* @param prefer - If set to "return=representation" the function will return an updated object
130136
* @param select - An Array representing the $select Query Option to control which attributes will be returned.
131137
*/
132-
upsert<T = any>(key: string, collection: string, object: Object, prefer?: string | string[], select?: string[]): Promise<T>;
138+
upsert<T = any>(key: string, collection: string, object: T, prefer?: string | string[], select?: string[]): Promise<T>;
133139
/**
134140
* Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number
135141
*
@@ -765,7 +771,7 @@ declare namespace DynamicsWebApi {
765771

766772
interface MultipleResponse<T = any> {
767773
/**Multiple respone entities */
768-
value?: T[];
774+
value: T[];
769775
oDataCount?: number;
770776
oDataContext?: string;
771777
}

0 commit comments

Comments
 (0)