You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fixing #153; moving breaking changes and a list of new features to md files; removing unused code; adding more unit tests; adding v1 github action to test the package
All modern browsers support Promises (including await/async). The main reason why the Callbacks version was added in the first place was Internet Explorer which has been replaced with Edge and is neither maintained or supported by Microsoft anymore.
5
+
6
+
### 2. Configuration object changes
7
+
`webApiUrl` and `webApiVersion` have been removed and replaced with `serverUrl`, `dataApi` and `searchApi`. [#139](https://github.com/AleksandrRogov/DynamicsWebApi/issues/139)
### 3. All request functions with multiple parameters are removed.
42
+
No more "simple" functions with multiple parameters. This has been done to streamline the request parameters and not introduce breaking changes when new parameters have been added. Furthermore, now all functions have access to impersonation, cache and data tracking functionality.
43
+
44
+
### 4. Changes to the names of some request functions and properties
45
+
46
+
| Old Name | New Name |
47
+
|--------|--------|
48
+
| createRequest | create |
49
+
| updateRequest | update |
50
+
| upsertRequest | upsert |
51
+
| deleteRequest | deleteRecord |
52
+
| retrieveRequest | retrieve |
53
+
| retrieveMultipleRequest | retrieveMultiple |
54
+
| retrieveAllRequest | retrieveAll |
55
+
| executeFetchXml | fetch |
56
+
| executeFetchXmlAll | fetchAll |
57
+
| executeBoundFunction | callFunction |
58
+
| executeUnboundFunction | callFunction |
59
+
| executeBoundAction | callAction |
60
+
| executeUnboundAction | callAction |
61
+
| utility | Utility |
62
+
63
+
### 5. In some requests `entity` property is replaced with `data`
64
+
Affected requests: `createRequest`, `updateRequest` and `upsertRequest` and their corresponding new names: `create`, `update` and `upsert`.
65
+
66
+
Example:
67
+
```js
68
+
constlead= {
69
+
subject:"Test WebAPI",
70
+
firstname:"Test",
71
+
lastname:"WebAPI",
72
+
jobtitle:"Title"
73
+
};
74
+
75
+
constresult=awaitdynamicsWebApi.create({
76
+
collection:"leads",
77
+
data: lead,
78
+
returnRepresentation:true
79
+
});
80
+
```
81
+
82
+
### 6. `config.onTokenRefresh` is now a promise-based function
83
+
Usage example:
84
+
```ts
85
+
const cca =newMSAL.ConfidentialClientApplication(msalConfig);
//function calls an external functionality that acquires a token and passes it to DynamicsWebApi
89
+
const acquireToken =async () => {
90
+
try {
91
+
returnawaitcca.acquireTokenByClientCredential({
92
+
scopes: [`${serverUrl}/.default`],
93
+
});
94
+
}
95
+
catch (error) {
96
+
//error logging here
97
+
//or a fallback authentication
98
+
99
+
//to abort a request just return null
100
+
//or re-throw an error
101
+
returnnull;
102
+
}
103
+
}
104
+
105
+
const dynamicsWebApi =newDynamicsWebApi({
106
+
serverUrl: serverUrl,
107
+
onTokenRefresh: acquireToken
108
+
});
109
+
```
110
+
111
+
### 7. Removed `id` property from the request object.
112
+
`id` has been deprecated for quite some time and got removed in v2. Use `key` instead.
113
+
114
+
### 8. Default version of Dataverse API is set to `9.2`
115
+
In case you still need version `8.0`, please set `dataApi.version` to `8.0`.
116
+
117
+
### 9. Supported minimum version of Node.js raised to v.15.0.0.
118
+
It was time to finally bump up the JavaScript specification from ES5 to ES2020 for the project. It is widely supported in all modern browsers and all currently maintained versions of Node. Even though the minimum Node.js version that supports ES2020 is 14.5.0, I would recommend running DynamicsWebApi on at least v.15.0.0 for all features to work correctly. In all versions prior to 15 the `AbortSignal` functionality won't work because it did not exist there yet.
DynamicsWebApi v2 has been fully rewritten in TypeScript. The process of rewriting the code made it possible to refactor and improve many modules of the library and organize them in a more logical way as well as to remove redundant features that were no longer needed. As a result, DynamicsWebApi now has many new features such as:
4
+
5
+
### Microsoft Dataverse Search API
6
+
v2 brings the power of Search, Suggest and Autocomplete capabilities of Microsoft Dataverse Search API.
7
+
8
+
### `AbortController` and `AbortSignal` support (for Node.js 15+ and Browser)
9
+
Each request can now be aborted when it's no longer need to be completed via the `AbortController`.
10
+
11
+
### All requests support Impersonation, NoCache and other common properties
12
+
v1 did not have full support of mentioned properties in some requests. v2 fixes that by making all request parameters implement a single `BaseRequest` interface.
13
+
14
+
### On demand Changesets in Batch Operations
15
+
Control what requests should be included or excluded from the changesets by setting `inChangeSet` parameter to `false` (it's `true` when no set). By default, all requests (except for GET) are included in a changeset. Thus, it does not break the core logic introduced in v1.
16
+
17
+
### CSDL $metadata document
18
+
Retrieve the org's CSDL $metadata document with a single call of `retrieveCsdlMetadata` function. The library returns the raw text and does not parse or process it in any way.
19
+
20
+
### NPM Package contents
21
+
NPM package now includes a pre-bundled code of DynamicsWebApi to simplify a compilation process of the projects that depend on it. There are 4 separate bundles:
22
+
-`dist/dynamics-web-api.js` - a Browser ready version (to use as a Dynamics 365 web resource) [IIFE] + it's minified version `.min.js`.
23
+
-`dist/cjs/dynamics-web-api.js` - a Node.js module [CommonJS].
24
+
-`dist/esm/dynamics-web-api.mjs` - a Node.js module [ESM].
25
+
-`dist/browser/esm/dynamics-web-api.js` - an ESM module for a Browser (to use as a Dynamics 365 web resource).
26
+
27
+
Type definition for the library also moved into the `dist` folder.
28
+
29
+
Please let me know (create an issue) if we need to add a `cjs` bundle for the Browser as well. I did not have any case where I had to use cjs specifically for the browser but it's just me :blush: and you may have a different case.
30
+
31
+
### Other changes
32
+
Not all changes are visible outside, some changes and fixes I've done were in the core of the library itself. Here are some of them:
33
+
- All request objects passed as function parameters are fully cloned and remain untouched. Which means, whatever has been passed into the functions is not getting modified in any way. This was not always true in v1 (and I admit that it was my mistake). It is a positive change because _input parameters should never be changed inside the functions_ (there are exceptions but not in this case).
34
+
- All deprecated JavaScript functions used by the library have been replaced with their modern alternatives.
35
+
- The core has been _promisified_, except for `xhr` and `http` modules. This makes the overall code cleaner and easier to follow.
36
+
- Rewriting to TypeScript gave me a chance to go through the code line by line and identify suboptimal functions/features which were successfully tweaked or removed.
37
+
38
+
...and other.
39
+
40
+
### Migration
41
+
42
+
If you are currently using v1 and planning on migrating to v2 please consult with a list of [breaking changes](/.github/BREAKING_CHANGES_V2.md).
Copy file name to clipboardExpand all lines: .github/README.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,14 @@ As well as Microsoft Dynamics 365 CE (online), Microsoft Dynamics 365 CE (on-pre
12
12
13
13
### **This documentation is for version 2.x. If you are working with version 1.x, please check [this instead](https://github.com/AleksandrRogov/DynamicsWebApi/tree/v1).**
14
14
15
-
Please check [DynamicsWebApi Wiki](../../wiki/) where you will find documentation to DynamicsWebApi API and more.
15
+
Please check [DynamicsWebApi Wiki](../../../wiki/) where you will find documentation to DynamicsWebApi API and more.
16
16
17
17
Browser-compiled script and type definitions can be found in a [dist](/dist/) folder.
18
18
19
19
## Main Features
20
20
21
-
-**Microsoft Dataverse Search API**. Access full power of its Search, Suggestion and Autocomplete capabilities.
22
-
-**Batch Requests**. Convert all requests into a Batch operation with a single line of code.
21
+
-**Microsoft Dataverse Search API**. Access the full power of its Search, Suggestion and Autocomplete capabilities.
22
+
-**Batch Requests**. Convert all requests into a Batch operation with two lines of code.
23
23
-**Simplicity and Automation**. Such as automated paging, big file downloading/uploading in chunks of data, automated conversion of requests with long URLs into a Batch Request in the background and more!
24
24
-**CRUD operations**. Including Fetch XML, Actions and Functions in Microsoft Dataverse Web API.
25
25
-**Table Definitions (Entity Metadata)**. Query and modify Table, Column, Choice (Option Set) and Relationship definitions.
@@ -46,6 +46,8 @@ Also, please check [suggestions and contributions](#contributions) section to le
46
46
47
47
## Table of Contents
48
48
49
+
* v2 breaking changes are [here](/.github/BREAKING_CHANGES_V2.md)
50
+
* List of new features in v2 is [here](/.github/NEW_IN_V2.md)
49
51
*[Getting Started](#getting-started)
50
52
*[Dynamics 365 Web Resource](#dynamics-365-web-resource)
51
53
*[Node.js](#nodejs)
@@ -121,7 +123,7 @@ Also, please check [suggestions and contributions](#contributions) section to le
121
123
### Dynamics 365 Web Resource
122
124
To use DynamicsWebApi inside Dynamics 365 you need to download a browser version of the library, it can be found in [dist](/dist/) folder.
123
125
124
-
Upload a script as a JavaScript Web Resource, add it to a table form or reference it in your HTML Web Resource and then initialize the main object:
126
+
Upload a script as a JavaScript Web Resource, add it to a table form or reference it in the HTML Web Resource and then initialize the main object:
console.log(`Hello from Dynamics 365! My id is: ${response.UserId}`);
@@ -269,7 +270,7 @@ If you are using `DynamicsWebApi` **outside Microsoft Dynamics 365** and set `us
269
270
| path |`string`| A path to API, for example: "data" or "search". Optional. |
270
271
| version |`string`| API Version, for example: "1.0" or "9.2". Optional. |
271
272
272
-
Both `dataApi` and `seatchApi` can be omitted from a configuration. Their default values are:
273
+
Both `dataApi` and `searchApi` can be omitted from a configuration. Their default values are:
273
274
274
275
```js
275
276
//dataApi
@@ -293,7 +294,7 @@ Both `dataApi` and `seatchApi` can be omitted from a configuration. Their defaul
293
294
294
295
## Request Examples
295
296
296
-
Please use [DynamicsWebApi Wiki](../../wiki/) for an object reference. It is automatically generated and I could not find a better doc generator, pardon me for that. If you know a good ".d.ts -> .md" doc generator - let me know!
297
+
Please use [DynamicsWebApi Wiki](./../../wiki/) for an object reference. It is automatically generated and I could not find a better doc generator, pardon me for that. If you know a good ".d.ts -> .md" doc generator - let me know!
297
298
298
299
The following table describes all __possible__ properties that can be set in `request` object.
299
300
@@ -2373,7 +2374,8 @@ If you are developing CRM Web Resources with TypeScript (and are not using NPM),
2373
2374
The declaration file is an ESM module, so if you are not using any bundler, you will have to add another d.ts file (let's call it `dynamics-web-api.browser.d.ts` and put it in the `types` folder) that will make DynamicsWebApi available globally. Here is an example (the same folder structure as mentioned above):
2374
2375
2375
2376
```ts
2376
-
//import a class from dynamics-web-api.d.ts file
2377
+
//dynamics-web-api.browser.d.ts
2378
+
//import a DynamicsWebApi class from dynamics-web-api.d.ts file
2377
2379
import { DynamicsWebApi } from"./dynamicsWebApi"
2378
2380
//make the DynamicsWebApi class available globally
2379
2381
export=DynamicsWebApi;
@@ -2408,7 +2410,7 @@ the config option "formatted" will enable developers to retrieve all information
2408
2410
- [X] Full proxy support. `Addedinv.1.7.2`.
2409
2411
- [X] Refactoring and conversion to TypeScript - coming with `v.2.0`! Stay tuned!
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
Copy file name to clipboardExpand all lines: README.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,9 +26,9 @@ Browser-compiled script and type definitions can be found in a [dist](/dist/) fo
26
26
27
27
**Please note!** "Dynamics 365" in this readme refers to Microsoft Dataverse (formerly known as Microsoft Common Data Service) / Microsoft Dynamics 365 Customer Engagement / Micorosft Dynamics CRM. **NOT** Microsoft Dynamics 365 Finance and Operations.
28
28
29
-
### For a full documentation please check [DynamicsWebApi on GitHub](https://github.com/AleksandrRogov/DynamicsWebApi).
29
+
##Usage examples
30
30
31
-
##Usage samples
31
+
### For a full documentation please check [DynamicsWebApi on GitHub](https://github.com/AleksandrRogov/DynamicsWebApi).
32
32
33
33
### Dynamics 365 Web Resource
34
34
To use DynamicsWebApi inside Dynamics 365 you need to download a browser version of the library, it can be found in [dist](/dist/) folder.
@@ -87,6 +87,8 @@ const contactId = responses[0];
87
87
const salesorderId =responses[1];
88
88
```
89
89
90
+
### For a full documentation please check [DynamicsWebApi on GitHub](https://github.com/AleksandrRogov/DynamicsWebApi).
91
+
90
92
## Contributions
91
93
92
94
First of all, I would like to thank you for using `DynamicsWebApi` library in your Dynamics 365 CE / Common Data Service project, the fact that my project helps someone to achieve their development goals already makes me happy.
0 commit comments