Skip to content

Commit 0c21005

Browse files
add: defenetely types. part 1
1 parent 48db0e1 commit 0c21005

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

DynamicsWebApi.njsproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
<Folder Include="lib\requests\" />
132132
<Folder Include="lib\requests\helpers\" />
133133
<Folder Include="dist\" />
134+
<Folder Include="types\" />
134135
<Folder Include="tests\" />
135136
<Folder Include="tests\browser\" />
136137
<Folder Include="typings\" />
@@ -141,6 +142,9 @@
141142
<Folder Include="typings\globals\sinon\" />
142143
</ItemGroup>
143144
<ItemGroup>
145+
<TypeScriptCompile Include="types\dynamics-web-api-callbacks.d.ts">
146+
<SubType>Code</SubType>
147+
</TypeScriptCompile>
144148
<TypeScriptCompile Include="typings\globals\chai\index.d.ts" />
145149
<TypeScriptCompile Include="typings\globals\mocha\index.d.ts" />
146150
<TypeScriptCompile Include="typings\globals\node\index.d.ts" />

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
declare namespace DynamicsWebApiNamespace {
2+
interface Expand {
3+
/**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */
4+
select: string[];
5+
/**Use the $filter system query option to set criteria for which entities will be returned. */
6+
filter: string;
7+
/**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */
8+
top: number
9+
/**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */
10+
orderBy: string[]
11+
/**A name of a single-valued navigation property which needs to be expanded. */
12+
property: string
13+
}
14+
interface Request {
15+
/**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */
16+
async: boolean;
17+
/**The name of the Entity Collection or Entity Logical name. */
18+
collection: string;
19+
/**A String representing the Primary Key(GUID) of the record. */
20+
id: string;
21+
/**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */
22+
select: string[];
23+
/**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */
24+
expand: Expand[];
25+
/**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */
26+
key: string;
27+
/**Use the $filter system query option to set criteria for which entities will be returned. */
28+
filter: string;
29+
/**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */
30+
maxPageSize: number;
31+
/**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */
32+
count: boolean;
33+
/**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */
34+
top: number;
35+
/**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */
36+
orderBy: string[];
37+
/**Sets Prefer header with value "odata.include-annotations=" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */
38+
includeAnnotations: string;
39+
/**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/
40+
ifmatch: string;
41+
/**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */
42+
ifnonematch: string;
43+
/**Sets Prefer header request with value "return=representation".Use this property to return just created or updated entity in a single request. */
44+
returnRepresentation: boolean;
45+
/**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single - valued navigation properties). */
46+
entity: any;
47+
/**Impersonates the user.A String representing the GUID value for the Dynamics 365 system user id. */
48+
impersonate: string;
49+
/**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */
50+
navigationProperty: string;
51+
/**v.1.4.3 + A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */
52+
navigationPropertyKey: string;
53+
/**v.1.4.3 + Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */
54+
metadataAttributeType: string;
55+
/** If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */
56+
noCache: boolean;
57+
/**A String representing the GUID value of the saved query. */
58+
savedQuery: string;
59+
/**A String representing the GUID value of the user query. */
60+
userQuery: string;
61+
/**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'.Default value is 'false' */
62+
mergeLabels: boolean;
63+
/**If set to 'true', DynamicsWebApi treats a request as a part of a batch request. Call ExecuteBatch to execute all requests in a batch. Default value is 'false'. */
64+
isBatch: boolean;
65+
}
66+
interface Config {
67+
/**A String representing the GUID value for the Dynamics 365 system user id.Impersonates the user. */
68+
webApiUrl: string;
69+
/**The version of Web API to use, for example: "8.1" */
70+
webApiVersion: string;
71+
/**A String representing a URL to Web API(webApiVersion not required if webApiUrl specified)[not used inside of CRM] */
72+
impersonate: string;
73+
/**A function that is called when a security token needs to be refreshed. */
74+
onTokenRefresh: Function;
75+
/**Sets Prefer header with value "odata.include-annotations=" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/
76+
includeAnnotations: string;
77+
/**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */
78+
maxPageSize: string;
79+
/**Sets Prefer header request with value "return=representation".Use this property to return just created or updated entity in a single request.*/
80+
returnRepresentation: boolean;
81+
/**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/
82+
useEntityNames: boolean;
83+
}
84+
interface Utility {
85+
/**
86+
* Searches for a collection name by provided entity name in a cached entity metadata.
87+
* The returned collection name can be null.
88+
* @param entityName - entity name
89+
*/
90+
getCollectionName(entityName: string): string;
91+
}
92+
}
93+
94+
interface DynamicsWebApi {
95+
setConfig(config: DynamicsWebApiNamespace.Config);
96+
createRequest(request: DynamicsWebApiNamespace.Request, successCallback: Function, errorCallback: Function);
97+
create(object: Object, collection: string, successCallback: Function, errorCallback: Function, prefer?: string | string[], select?: string[]);
98+
updateRequest(request: DynamicsWebApiNamespace.Request, successCallback: Function, errorCallback: Function);
99+
update(key: string, collection: string, object: Object, successCallback: Function, errorCallback: Function, prefer?: string | string[], select?: string[]);
100+
updateSingleProperty(key: string, collection: string, keyValuePair: Object, successCallback: Function, errorCallback: Function, prefer?: string | string[], select?: string[]);
101+
deleteRequest(request: DynamicsWebApiNamespace.Request, successCallback: Function, errorCallback: Function);
102+
deleteRecord(key: string, collection: string, successCallback: Function, errorCallback: Function, propertyName?: string);
103+
retrieveRequest(request: DynamicsWebApiNamespace.Request, successCallback: Function, errorCallback: Function);
104+
retrieve(key: string, collection: string, successCallback: Function, errorCallback: Function, select?: string[], expand?: DynamicsWebApiNamespace.Expand[]);
105+
upsertRequest(request: DynamicsWebApiNamespace.Request, successCallback: Function, errorCallback: Function);
106+
upsert(key: string, collection: string, object: Object, successCallback: Function, errorCallback: Function, prefer?: string | string[], select?: string[]);
107+
count(collection: string, successCallback: Function, errorCallback: Function, filter?: string);
108+
countAll(collection: string, successCallback: Function, errorCallback: Function, filter?: string, select?: string[]);
109+
retrieveMultiple(collection: string, successCallback: Function, errorCallback: Function, select?: string[], filter?: string, nextPageLink?: string);
110+
retrieveAll(collection: string, successCallback: Function, errorCallback: Function, select?: string[], filter?: string);
111+
retrieveMultipleRequest(request: DynamicsWebApiNamespace.Request, successCallback: Function, errorCallback: Function);
112+
retrieveAllRequest(request: DynamicsWebApiNamespace.Request, successCallback: Function, errorCallback: Function);
113+
executeFetchXml(collection: string, fetchXml: string, successCallback: Function, errorCallback: Function, includeAnnotations?: string, pageNumber?: number, pagingCookie?: string, impersonateUserId?: string);
114+
fetch(collection: string, fetchXml: string, successCallback: Function, errorCallback: Function, includeAnnotations?: string, pageNumber?: number, pagingCookie?: string, impersonateUserId?: string);
115+
executeFetchXmlAll(collection: string, fetchXml: string, successCallback: Function, errorCallback: Function, includeAnnotations?: string, impersonateUserId?: string);
116+
fetchAll(collection: string, fetchXml: string, successCallback: Function, errorCallback: Function, includeAnnotations?: string, impersonateUserId?: string);
117+
associate(collection: string, primaryKey: string, relationshipName: string, relatedCollection: string, relatedKey: string, successCallback: Function, errorCallback: Function, impersonateUserId?: string);
118+
disassociate(collection: string, primaryKey: string, relationshipName: string, relatedKey: string, successCallback: Function, errorCallback: Function, impersonateUserId?: string);
119+
associateSingleValued(collection: string, key: string, singleValuedNavigationPropertyName: string, relatedCollection: string, relatedKey: string, successCallback: Function, errorCallback: Function, impersonateUserId?: string);
120+
disassociateSingleValued(collection: string, key: string, singleValuedNavigationPropertyName: string, successCallback: Function, errorCallback: Function, impersonateUserId?: string);
121+
executeUnboundFunction(functionName: string, successCallback: Function, errorCallback: Function, parameters?: Object, impersonateUserId?: string);
122+
executeBoundFunction(id: string, collection: string, functionName: string, successCallback: Function, errorCallback: Function, parameters?: Object, impersonateUserId?: string);
123+
executeUnboundAction(actionName: string, requestObject: Object, successCallback: Function, errorCallback: Function, impersonateUserId?: string);
124+
executeBoundAction(id: string, collection: string, actionName: string, requestObject: Object, successCallback: Function, errorCallback: Function, impersonateUserId?: string);
125+
createEntity(entityDefinition: Object, successCallback: Function, errorCallback: Function);
126+
updateEntity(entityDefinition: Object, successCallback: Function, errorCallback: Function, mergeLabels?: boolean);
127+
retrieveEntity(entityKey: string, successCallback: Function, errorCallback: Function, select?: string[], expand?: DynamicsWebApiNamespace.Expand[]);
128+
retrieveEntities(successCallback: Function, errorCallback: Function, select?: string[], filter?: string);
129+
createAttribute(entityKey: string, attributeDefinition: Object, successCallback: Function, errorCallback: Function);
130+
updateAttribute(entityKey: string, attributeDefinition: Object, successCallback: Function, errorCallback: Function, attributeType?: string, mergeLabels?: boolean);
131+
retrieveAttributes(entityKey: string, successCallback: Function, errorCallback: Function, attributeType?: string, select?: string[], filter?: string, expand?: DynamicsWebApiNamespace.Expand[]);
132+
retrieveAttribute(entityKey: string, attributeKey: string, successCallback: Function, errorCallback: Function, attributeType?: string, select?: string[], expand?: DynamicsWebApiNamespace.Expand[]);
133+
createRelationship(relationshipDefinition: Object, successCallback: Function, errorCallback: Function);
134+
updateRelationship(relationshipDefinition: Object, successCallback: Function, errorCallback: Function, relationshipType?: string, mergeLabels?: boolean);
135+
deleteRelationship(metadataId: string, successCallback: Function, errorCallback: Function);
136+
retrieveRelationships(successCallback: Function, errorCallback: Function, relationshipType?: string, select?: string[], filter?: string);
137+
retrieveRelationship(metadataId: string, successCallback: Function, errorCallback: Function, relationshipType?: string, select?: string[]);
138+
createGlobalOptionSet(globalOptionSetDefinition: Object, successCallback: Function, errorCallback: Function);
139+
updateGlobalOptionSet(globalOptionSetDefinition: Object, successCallback: Function, errorCallback: Function, mergeLabels?: boolean);
140+
deleteGlobalOptionSet(globalOptionSetKey: string, successCallback: Function, errorCallback: Function);
141+
retrieveGlobalOptionSet(globalOptionSetKey: string, successCallback: Function, errorCallback: Function, castType?: string, select?: string[]);
142+
retrieveGlobalOptionSets(successCallback: Function, errorCallback: Function, castType?: string, select?: string[]);
143+
startBatch();
144+
executeBatch(successCallback: Function, errorCallback: Function);
145+
initializeInstance(config?: DynamicsWebApiNamespace.Config): DynamicsWebApi;
146+
utility: DynamicsWebApiNamespace.Utility;
147+
}

0 commit comments

Comments
 (0)