scottdurow / dataverse-ify Goto Github PK
View Code? Open in Web Editor NEWEasily call the Dataverse WebApi from TypeScript using SDK style types, with a NodeJS implementation for integration testing.
License: MIT License
Easily call the Dataverse WebApi from TypeScript using SDK style types, with a NodeJS implementation for integration testing.
License: MIT License
Hi,
I'm trying to use the dataverse-ify functionality to set up some integration tests. When I attempt to run npm test integration to begin executing the tests, it fails with the error:
`Configuration property "nodewebapi" is not defined
12 | beforeEach(async () => {
13 | XrmMockGenerator.initialise();
> 14 | await SetupGlobalContext();
| ^
15 | setMetadataCache(metadataCache);
16 | Xrm.Utility.showProgressIndicator = jest.fn();
17 | Xrm.Utility.closeProgressIndicator = jest.fn();
at Config.Object.<anonymous>.Config.get (../../../../Users/olive/AppData/Roaming/npm/node_modules/dataverse-ify/node_modules/config/lib/config.js:182:11)`
I can see the nodewebai property in my test.yaml file and it is null but the instructions seem to suggest thats correct?
I've also noticed (not sure if related or not, but in the dataverse-ify module from npm, an compile time error is being returned around the XrmStatic.ts class, stating:
{ "resource": "/c:/Dynamics/Training/dev1_tsjs/clientjs/node_modules/dataverse-ify/src/webapi/XrmStatic.ts", "owner": "typescript", "code": "2739", "severity": 8, "message": "Type 'NodeXrmUtilityStatic' is missing the following properties from type 'Utility': getLearningPathAttributeName, getPageContext", "source": "ts", "startLineNumber": 22, "startColumn": 7, "endLineNumber": 22, "endColumn": 36 }
Thanks
Oli
I was just generated the Email
entity and there's a column named descriptionblobid
of type FileType
here's what I get in VsCode:
// Description File Id FileType File that contains description content.
descriptionblobid?: FileType | null;
where FileType
is unknown, I'm not using that field right now and I can think of a workaround for it that is just creating a utility file with
type FileSystem = string;
OR
descriptionblobid?: string | null;
and then fix every time we regenerate the file. Any advise is greatly appreciated, thanks
I logged in Dataverse and generated the token, but when I try to execute npx dataverse-gen init
I get the following error:
node:internal/modules/cjs/loader:988
throw err;
^
Error: Cannot find module 'dataverse-ify/lib/xrm-webapi/TokenCache'
Require stack:
- C:\Users\alber\AppData\Roaming\npm\node_modules\dataverse-gen\lib\index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\alber\AppData\Roaming\npm\node_modules\dataverse-gen\lib\index.js:19:22)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\alber\\AppData\\Roaming\\npm\\node_modules\\dataverse-gen\\lib\\index.js'
]
}
I also tried to move this file inside the node_modules folder and then it works, but I would prefer to not to do this. When I change node_modules\dataverse-gen\lib\index.js line 19 from const TokenCache_1 = require("dataverse-ify/lib/xrm-webapi/TokenCache");
to const TokenCache_1 = require("dataverse-ify/lib/webapi/TokenCache");
it works fine.
VERSION: 1.0.13
Hi Scott, Thanks for the great library and your course on PCF!
Is there a package you would know of or recommend with the same functionality as your Typescript Datavers-ify, except in C# for .NET Core that would let you generate early bound classes and work with the WebAPI similar to working with the .NET Framework Org Service?
Hi Scott. This project is a fantastic initiative. Great! :)
Some issues I've found so far:
Not all attributes are generated in the form context. For example, parentaccountid on opportunity is not generated in the form context.
And some mistakes in the types in the form context. For example, I have a mulitselect option set which get set to Xrm.Attributes.OptionSetAttribute and Xrm.Attributes.OptionSetControl.
But no biggie, these are easily overridden with the base Form Context.
Now it returns the request.
Hello @scottdurow,
I'm sorry but, this was the best way I could find to contact you.
I just created a generator for creating Web Resources using Typescript, and wanted to get your thought on it, it's already usable but it's long ways from done.
Please let me know what you think
Have a great day
When configuring test.yaml, allow trailing / in the hostname when resolving the authentication profile inside SetupGlobalContext.ts
See #19
Is it possible to generate an enum to allow entity forms to be referenced? So, for example, if I want to use Xrm.Navigation.openForm I could use something like formId: Account.Forms.MyMainForm in entityFormOptions?
Hi,
I'm using dataverse-ify version 2.0.7. I'm trying to send a batch request using the executeMultiple
function. When the target object contains a lookup field with undefined/null value, I get the below error.
Error identified in Payload provided by the user for Entity :'(entity name removed)', For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293
----> InnerException : Microsoft.Crm.CrmException: Invalid property '(lookup field name removed)' was found in entity 'Microsoft.Dynamics.CRM.(entity name removed)'.
---> Microsoft.OData.ODataException: Does not support untyped value in non-open type.
I also checked the normal create
function and got the same error. The target object looks like this:
{
logicalName: "new_entityname",
new_name: "some name",
new_lookupfield: null
}
Unfortunately I get the following error while doing the quick-start :
Fetching EDMX metadata
√ Select entities to include [type to filter list, space to select] · AttributeMetadata, EntityMetadata, OptionSetMetadata, account
√ Select actions to include [type to filter list, space to select] · No items were selected
√ Select functions to include [type to filter list, space to select] · No items were selected
No items added to configuration
√ Would you like to generate the types now? (y/N) · true
Fetching EDMX metadata
Fetching CDS metadata for AttributeMetadata
Error:Cannot read properties of undefined (reading 'LogicalName')
Stack:TypeError: Cannot read properties of undefined (reading 'LogicalName')
at SchemaGenerator.<anonymous> (C:\Users\x\AppData\Local\npm-cache\_npx\25e184db857706b9\node_modules\dataverse-gen\lib\SchemaGenerator.js:98:37)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\x\AppData\Local\npm-cache\_npx\25e184db857706b9\node_modules\dataverse-gen\lib\SchemaGenerator.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
{}
What I am doing wrong?
I tried to select different options but the info No items added to configuration
does still appear. I also tried to select only the account. This message did not display if I select a action too:
Fetching EDMX metadata
√ Select entities to include [type to filter list, space to select] · account
√ Select actions to include [type to filter list, space to select] · AddToQueue
√ Select functions to include [type to filter list, space to select] · No items were selected
Configuration updated:
0 entities(s) added
1 actions(s) added
0 functions(s) added
√ Would you like to generate the types now? (y/N) · true
Fetching EDMX metadata
Fetching CDS metadata for AttributeMetadata
Error:Cannot read properties of undefined (reading 'LogicalName')
Stack:TypeError: Cannot read properties of undefined (reading 'LogicalName')
at SchemaGenerator.<anonymous> (C:\Users\x\AppData\Local\npm-cache\_npx\25e184db857706b9\node_modules\dataverse-gen\lib\SchemaGenerator.js:98:37)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\x\AppData\Local\npm-cache\_npx\25e184db857706b9\node_modules\dataverse-gen\lib\SchemaGenerator.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
{}
But the generation does still fail.
Something else: After the installation of the required packages I got several vulnerabilities:
# npm audit report
electron *
Severity: high
Depends on vulnerable versions of @electron/get
Renderers can obtain access to random bluetooth device without permission in Electron - https://github.com/advisories/GHSA-3p22-ghq8-v749
Compromised child renderer processes could obtain IPC access without nodeIntegrationInSubFrames being enabled - https://github.com/advisories/GHSA-mq8j-3h7h-p8g7
AutoUpdater module fails to validate certain nested components of the bundle - https://github.com/advisories/GHSA-77xc-hjv8-ww97
Electron's sandboxed renderers can obtain thumbnails of arbitrary files through the nativeImage API - https://github.com/advisories/GHSA-mpjm-v997-c4h4
IPC messages delivered to the wrong frame in Electron - https://github.com/advisories/GHSA-hvf8-h2qh-37m9
Google Chrome base/memory/weak_ptr.h WeakPtr Class Template Use-after-free DoS Weakness - https://github.com/chromium/chromium/commit/0b308a0e37b9d14a335c3b487511b7117c98d74b,https://bugs.chromium.org/p/chromium/issues/detail?id=817982,https://github.com/electron/electron/commit/3ad830c8044d3b194bfffcbf9d58c79d5b2b7e2a,https://github.com/electron/electron/pull/26438,https://github.com/electron/electron/releases/tag/v10.1.6
Google Chrome ANGLE Unspecified Out-of-bounds Read Memory Disclosure - https://github.com/electron/electron/releases/tag/v16.1.1,https://github.com/electron/electron/releases/tag/v15.4.2,https://github.com/electron/electron/releases/tag/v14.2.8,https://security-tracker.debian.org/tracker/CVE-2022-0792,https://www.debian.org/security/2022/dsa-5089,https://forums.opensuse.org/showthread.php/567514-openSUSE-SU-2022-0075-1-important-Security-update-for-chromium,https://www.forbes.com/sites/gordonkelly/2022/03/02/google-chrome-warning-upgrade-hack-security-new-chrome-update/,https://docs.microsoft.com/en-us/DeployEdge/microsoft-edge-relnotes-security#march-3-2022,https://bugs.chromium.org/p/chromium/issues/detail?id=1285885,http://cve.mitre.org/cgi-bin/cvename.cgi?name=2022-0792,https://chromereleases.googleblog.com/2022/03/stable-channel-update-for-desktop.html
Google Chrome MediaStream Unspecified Use-after-free Issue - https://github.com/electron/electron/releases/tag/v16.1.1,https://github.com/electron/electron/releases/tag/v15.4.2,https://github.com/electron/electron/releases/tag/v14.2.8,https://security-tracker.debian.org/tracker/CVE-2022-0798,https://www.debian.org/security/2022/dsa-5089,https://forums.opensuse.org/showthread.php/567514-openSUSE-SU-2022-0075-1-important-Security-update-for-chromium,https://docs.microsoft.com/en-us/DeployEdge/microsoft-edge-relnotes-security#march-3-2022,https://bugs.chromium.org/p/chromium/issues/detail?id=1283402,http://cve.mitre.org/cgi-bin/cvename.cgi?name=2022-0798,https://chromereleases.googleblog.com/2022/03/stable-channel-update-for-desktop.html
Google Chrome Unspecified High Severity Issue (1305655) - https://github.com/electron/electron/releases/tag/v14.2.9,https://github.com/electron/electron/releases/tag/v16.2.0,https://github.com/electron/electron/releases/tag/v15.5.0,https://bugs.chromium.org/p/chromium/issues/detail?id=1296876,https://bugs.chromium.org/p/chromium/issues/detail?id=1305655,https://chromereleases.googleblog.com/2022/03/stable-channel-update-for-desktop_15.html
Google Chrome ANGLE Unspecified Use-after-free Arbitrary Code Execution (2022-0978) - https://github.com/electron/electron/releases/tag/v16.2.0,https://kb.igel.com/securitysafety/en/isn-2022-07-chromium-browser-vulnerabilities-57327412.html,https://www.debian.org/security/2022/dsa-5104,https://docs.microsoft.com/en-us/deployedge/microsoft-edge-relnotes-security#march-17-2022,https://www.forbes.com/sites/gordonkelly/2022/03/16/google-issues-warning-for-millions-of-chrome-users/,https://bugs.chromium.org/p/chromium/issues/detail?id=1299264,http://cve.mitre.org/cgi-bin/cvename.cgi?name=2022-0978,https://chromereleases.googleblog.com/2022/03/stable-channel-update-for-desktop_15.html
Google Chrome GPU Unspecified Heap Buffer Overflow - https://github.com/electron/electron/releases/tag/v14.2.9,https://github.com/electron/electron/releases/tag/v16.2.0,https://github.com/electron/electron/releases/tag/v16.1.1,https://github.com/electron/electron/releases/tag/v15.4.2,https://kb.igel.com/securitysafety/en/isn-2022-07-chromium-browser-vulnerabilities-57327412.html,https://bugzilla.suse.com/show_bug.cgi?id=1197163,https://forums.opensuse.org/showthread.php/567998-openSUSE-SU-2022-0085-1-important-Security-update-for-chromium,https://www.debian.org/security/2022/dsa-5104,https://docs.microsoft.com/en-us/deployedge/microsoft-edge-relnotes-security#march-17-2022,https://www.forbes.com/sites/gordonkelly/2022/03/16/google-issues-warning-for-millions-of-chrome-users/,https://bugs.chromium.org/p/chromium/issues/detail?id=1296866,http://cve.mitre.org/cgi-bin/cvename.cgi?name=2022-0976,https://chromereleases.googleblog.com/2022/03/stable-channel-update-for-desktop_15.html
Side-channel information leakage in autofill in Google Chrome prior to 89.0.4389.72 allowed a remote attacker to obtain potentially sensitive information from process memory via a crafted HTML page. - https://crbug.com/1182767,https://chromereleases.googleblog.com/2021/03/stable-channel-update-for-desktop.html
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/electron
dataverse-auth <=1.0.9
Depends on vulnerable versions of electron
node_modules/dataverse-auth
got <11.8.5
Severity: moderate
Got allows a redirect to a UNIX socket - https://github.com/advisories/GHSA-pfrx-2q88-qq97
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/got
@electron/get <=1.14.1
Depends on vulnerable versions of got
node_modules/@electron/get
4 vulnerabilities (1 low, 2 moderate, 1 high)
I installed NodeJS and did the quick-start.
Move to using node-fetch for node requests, and just fetch for browser requests.
I can't seem to get my config.server configured. When I run "jest integration" in terminal I get the following error:
config.server not configured
at Function.<anonymous> (node_modules/dataverse-ify/src/webapi/XrmStatic.ts:26:15)
at node_modules/dataverse-ify/lib/webapi/XrmStatic.js:8:71
at Object.<anonymous>.__awaiter (node_modules/dataverse-ify/lib/webapi/XrmStatic.js:4:12)
at Function.createInstance (node_modules/dataverse-ify/lib/webapi/XrmStatic.js:17:16)
at node_modules/dataverse-ify/src/webapi/SetupGlobalContext.ts:36:39
at node_modules/dataverse-ify/lib/webapi/SetupGlobalContext.js:8:71
My configuration is as follows:
test.yaml file is present in a config folder directly under the root directory. Am I missing a step to configure credentials?
test.yaml contains the following configuration:
nodewebapi: logging: verbose server: host: https://[my environment].dynamics.com version: 9.1
however in the dataverse-ify integration instructions it says to use this:
nodecds: server: host: https://someorg.crm11.dynamics.com version: 9.1
import { SetupGlobalContext } from "dataverse-ify/lib/webapi";
present in integration.AccountRibbon.test.ts
serviceClient set to const serviceClient = new XrmContextCdsServiceClient(Xrm.WebApi);
Ran npx node-cds-auth to get refreshToken
I tried updating the version in the test.yaml to 9.2. I also tried using a host = "https://[my environment].api.crm.dynamics.com"
Can you help me troubleshoot what I might be missing in my configuration?
Hi Scott,
Is it possible to use dataverse-ify, specifically dataverse-gen, with Dynamics 365 v8.2 On-Premise using AD authentication?
Hi @scottdurow ,
First of all, thank you so much for this amazing package. Once again you are leading the parade ;).
I found a small glitch with the Odataify function when trying to declare lookups (navigation) on an entity.
The early bound properties on a given record are based on the LogicalName but the Odata statement needs to be bound on the SchemaName.
There is no problems if the schema name is all lowercase (thus LogicalName = SchemaName), but when there are uppercase characters in the schema name, the call to Odataify gives an error.
The source of the error seems to be on this call:
I will try to submit a PR with a solution.
Thanks!
First of all, thanks for sharing such a developer friendly TS tool and I can see the values that you bring in TS as like spkl library.
By the way, I tried to retrieveMultiple with strong typing as like below but getting DomParser error.
await SetupGlobalContext();
const cdsServiceClient = new XrmContextCdsServiceClient(Xrm.WebApi);
const fetch = `
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="tst_category">
<attribute name="tst_categoryid" />
<attribute name="tst_name" />
</entity>
</fetch>
`;
const categories= (await cdsServiceClient.retrieveMultiple<tst_category>(fetch));
categories.entities.forEach(e => {
console.log(e)
})
Could you provide an example to update multiple records.
I work in laboratory software development and have a test case where a customer will submit an order that has multiple associated samples destined for laboratory testing. I was trying to create a ribbon button on the order where a user could set all the sample records to received. I need to
I could not find an example in the documentation so am a bit stuck.
Best practice is to use strict equality in typescript.
Hi Scott,
Really interesting stuff thanks for sharing. I think the "early bound" generation of the entity classes that are compatible with @types/xrm is really nice. Would it be possible to add an option to solely generate those classes? That might make CDSify easier to get integrated with existing code bases.
What are the primary motivations for this library and what advantages/disadvantages may I find in using it, as compared to XrmDefinitelyTyped?
moment 2.18.0 - 2.29.3
Severity: high
Inefficient Regular Expression Complexity in moment - GHSA-wc69-rhjr-hc9g
fix available via npm audit fix
node_modules/moment
1 high severity vulnerability
When running dataverse-gen to generate early bindings for my opportunity, I am seeing the following code generated for
the opendeals_date attribute. This is a built in attribute on opportunity.
// Open Deals(Last Updated Time)
DateTimeType The date time for Open Deals. DateAndTime:UserLocal
opendeals_date?: Date | null;
Also this a few lines below: -
// Open Revenue(Last Updated Time)
DateTimeType The date time for Open Revenue. DateAndTime:UserLocal
openrevenue_date?: Date | null;
There are 18 DateTime fields in my opportunity, and only 2 show this problem.
The only thing that stands out to me is the fact that in the two failed cases the display name ends in a ")"
Some obscure bug with regexes causing a spurious carriage return, perhaps?
Using CRM online Database version 9.2.21071.00134. 2021 Release Wave 1.
Dataversify version 1.0.10
Hello @scottdurow ,
I have the following issue when running the gulp task.
The issue seams to be in the webpack.config.js
Do you have any ideas?
Token Aquisition Completed
C:\Projects\Typescript-Webresources\clientjs>npx dataverse-gen init
Cannot find module 'dataverse-ify/lib/xrm-webapi/TokenCache'
Require stack:
Getting above error
Hi,
Once i'm doing npx node-cds-gen [tennant] [environment] with my environments details, I'm getting this error
`npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/node-cds-gen - Not found
npm ERR! 404
npm ERR! 404 'node-cds-gen@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\abodh\AppData\Roaming\npm-cache_logs\2020-05-05T21_13_08_353Z-debug.log
Install for [ 'node-cds-gen@latest' ] failed with code 1`
2020-05-05T21_13_08_353Z-debug.log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.