Socket
Socket
Sign inDemoInstall

dynamics-web-api

Package Overview
Dependencies
6
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.7.6 to 1.7.7

3

lib/dynamics-web-api.js

@@ -774,4 +774,3 @@ "use strict";

//add page number and paging cookie to fetch xml
if (replacementString)
fetchXml = fetchXml.replace(/^(<fetch)/, replacementString);
if (replacementString) fetchXml = fetchXml.replace(/^(<fetch)/, replacementString);
}

@@ -778,0 +777,0 @@

@@ -1,5 +0,5 @@

var DWA = require('../../dwa');
var Utility = require('../../utilities/Utility');
var ErrorHelper = require('../../helpers/ErrorHelper');
var dateReviver = require('./dateReviver');
var DWA = require("../../dwa");
var Utility = require("../../utilities/Utility");
var ErrorHelper = require("../../helpers/ErrorHelper");
var dateReviver = require("./dateReviver");

@@ -13,36 +13,26 @@ //string es6 polyfill

var newKey = null;
if (keyName.indexOf('@') !== -1) {
var format = keyName.split('@');
if (keyName.indexOf("@") !== -1) {
var format = keyName.split("@");
switch (format[1]) {
case 'odata.context':
newKey = 'oDataContext';
case "odata.context":
newKey = "oDataContext";
break;
case 'odata.count':
newKey = 'oDataCount';
value = value != null
? parseInt(value)
: 0;
case "odata.count":
newKey = "oDataCount";
value = value != null ? parseInt(value) : 0;
break;
case '@Microsoft.Dynamics.CRM.totalrecordcount':
newKey = "microsoftTotalRecordCount";
value = value === "true";
case "odata.nextLink":
newKey = "oDataNextLink";
break;
case '@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded':
newKey = "microsoftTotalRecordCountLimitExceeded";
value = value === "true";
case "odata.deltaLink":
newKey = "oDataDeltaLink";
break;
case 'odata.nextLink':
newKey = 'oDataNextLink';
break;
case 'odata.deltaLink':
newKey = 'oDataDeltaLink';
break;
case DWA.Prefer.Annotations.FormattedValue:
newKey = format[0] + '_Formatted';
newKey = format[0] + "_Formatted";
break;
case DWA.Prefer.Annotations.AssociatedNavigationProperty:
newKey = format[0] + '_NavigationProperty';
newKey = format[0] + "_NavigationProperty";
break;
case DWA.Prefer.Annotations.LookupLogicalName:
newKey = format[0] + '_LogicalName';
newKey = format[0] + "_LogicalName";
break;

@@ -68,3 +58,3 @@ }

if (parseParams.toCount) {
return getFormattedKeyValue('@odata.count', object['@odata.count'])[1] || 0;
return getFormattedKeyValue("@odata.count", object["@odata.count"])[1] || 0;
}

@@ -83,4 +73,3 @@ }

}
}
else if (typeof (object[currentKey]) === "object") {
} else if (typeof object[currentKey] === "object") {
parseData(object[currentKey]);

@@ -97,13 +86,14 @@ }

//parse aliased values
if (currentKey.indexOf('_x002e_') !== -1) {
var aliasKeys = currentKey.split('_x002e_');
if (currentKey.indexOf("_x002e_") !== -1) {
var aliasKeys = currentKey.split("_x002e_");
if (!object.hasOwnProperty(aliasKeys[0])) {
object[aliasKeys[0]] = { _dwaType: 'alias' };
object[aliasKeys[0]] = { _dwaType: "alias" };
}
//throw an error if there is already a property which is not an 'alias'
else if (
typeof object[aliasKeys[0]] !== 'object' ||
typeof object[aliasKeys[0]] === 'object' && !object[aliasKeys[0]].hasOwnProperty('_dwaType')) {
throw new Error('The alias name of the linked entity must be unique!');
typeof object[aliasKeys[0]] !== "object" ||
(typeof object[aliasKeys[0]] === "object" && !object[aliasKeys[0]].hasOwnProperty("_dwaType"))
) {
throw new Error("The alias name of the linked entity must be unique!");
}

@@ -122,4 +112,4 @@

if (parseParams) {
if (parseParams.hasOwnProperty('pageNumber') && object['@' + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {
object.PagingInfo = Utility.getFetchXmlPagingCookie(object['@' + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);
if (parseParams.hasOwnProperty("pageNumber") && object["@" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {
object.PagingInfo = Utility.getFetchXmlPagingCookie(object["@" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);
}

@@ -147,4 +137,3 @@ }

headers[parts[1].toLowerCase()] = parts[2];
}
else {
} else {
// Whatever was found is not a header, so reset the context position.

@@ -191,3 +180,3 @@ ctx.position = pos;

// so we have to extract it.
var delimiter = response.substr(0, response.indexOf('\r\n'));
var delimiter = response.substr(0, response.indexOf("\r\n"));
var batchResponseParts = response.split(delimiter);

@@ -204,10 +193,8 @@ // The first part will always be an empty string. Just remove it.

var batchResponse = batchResponseParts[i];
if (batchResponse.indexOf('--changesetresponse_') > -1) {
if (batchResponse.indexOf("--changesetresponse_") > -1) {
batchResponse = batchResponse.trim();
var batchToProcess = batchResponse
.substring(batchResponse.indexOf('\r\n') + 1).trim();
var batchToProcess = batchResponse.substring(batchResponse.indexOf("\r\n") + 1).trim();
result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));
}
else {
} else {
//check http status

@@ -227,34 +214,32 @@ var httpStatusReg = /HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/gm.exec(batchResponse);

result.push(isNaN(plainContent) ? plainContent : parseInt(plainContent));
}
else
if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty('valueIfEmpty')) {
result.push(parseParams[requestNumber].valueIfEmpty);
}
else {
var entityUrl = /OData-EntityId.+/i.exec(batchResponse);
} else if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty("valueIfEmpty")) {
result.push(parseParams[requestNumber].valueIfEmpty);
} else {
var entityUrl = /OData-EntityId.+/i.exec(batchResponse);
if (entityUrl && entityUrl.length) {
var guidResult = /([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})\)$/i.exec(entityUrl[0]);
if (entityUrl && entityUrl.length) {
var guidResult = /([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})\)$/i.exec(entityUrl[0]);
result.push(guidResult ? guidResult[1] : undefined);
}
else {
result.push(undefined);
}
result.push(guidResult ? guidResult[1] : undefined);
} else {
result.push(undefined);
}
}
else {
}
} else {
var parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);
if (httpStatus >= 400) {
var responseHeaders = parseBatchHeaders(batchResponse.substring(batchResponse.indexOf(httpStatusReg[0]) + httpStatusReg[0].length + 1, batchResponse.indexOf("{")));
var responseHeaders = parseBatchHeaders(
batchResponse.substring(batchResponse.indexOf(httpStatusReg[0]) + httpStatusReg[0].length + 1, batchResponse.indexOf("{"))
);
result.push(ErrorHelper.handleHttpError(parsedResponse, {
status: httpStatus,
statusText: httpStatusMessage,
statusMessage: httpStatusMessage,
headers: responseHeaders
}));
}
else {
result.push(
ErrorHelper.handleHttpError(parsedResponse, {
status: httpStatus,
statusText: httpStatusMessage,
statusMessage: httpStatusMessage,
headers: responseHeaders,
})
);
} else {
result.push(parsedResponse);

@@ -275,4 +260,3 @@ }

return Buffer.from(base64, "base64").toString("binary");
}
else if (typeof window !== "undefined")
} else if (typeof window !== "undefined")
/* develblock:end */

@@ -285,3 +269,3 @@ return window.atob(base64);

if (parseParams.hasOwnProperty('parse')) {
if (parseParams.hasOwnProperty("parse")) {
data = JSON.parse(data).value;

@@ -292,13 +276,10 @@ data = base64ToString(data);

var parseResult = {
value: data
value: data,
};
if (responseHeaders['x-ms-file-name'])
parseResult.fileName = responseHeaders['x-ms-file-name'];
if (responseHeaders["x-ms-file-name"]) parseResult.fileName = responseHeaders["x-ms-file-name"];
if (responseHeaders['x-ms-file-size'])
parseResult.fileSize = parseInt(responseHeaders['x-ms-file-size']);
if (responseHeaders["x-ms-file-size"]) parseResult.fileSize = parseInt(responseHeaders["x-ms-file-size"]);
if (hasHeader(responseHeaders, 'Location'))
parseResult.location = getHeader(responseHeaders, 'Location');
if (hasHeader(responseHeaders, "Location")) parseResult.location = getHeader(responseHeaders, "Location");

@@ -313,4 +294,3 @@ return parseResult;

function getHeader(headers, name) {
if (headers[name])
return headers[name];
if (headers[name]) return headers[name];

@@ -330,40 +310,31 @@ return headers[name.toLowerCase()];

if (response.length) {
if (response.indexOf('--batchresponse_') > -1) {
if (response.indexOf("--batchresponse_") > -1) {
var batch = parseBatchResponse(response, parseParams);
parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch
? batch[0]
: batch;
}
else {
if (hasHeader(responseHeaders, 'Content-Disposition')) {
parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;
} else {
if (hasHeader(responseHeaders, "Content-Disposition")) {
parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);
}
else {
} else {
parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);
}
}
}
else {
if (parseParams.length && parseParams[0].hasOwnProperty('valueIfEmpty')) {
} else {
if (parseParams.length && parseParams[0].hasOwnProperty("valueIfEmpty")) {
parseResult = parseParams[0].valueIfEmpty;
}
else
if (hasHeader(responseHeaders, 'OData-EntityId')) {
var entityUrl = getHeader(responseHeaders, 'OData-EntityId');
} else if (hasHeader(responseHeaders, "OData-EntityId")) {
var entityUrl = getHeader(responseHeaders, "OData-EntityId");
var guidResult = /([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})\)$/i.exec(entityUrl);
var guidResult = /([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})\)$/i.exec(entityUrl);
if (guidResult) {
parseResult = guidResult[1];
}
if (guidResult) {
parseResult = guidResult[1];
}
else if (hasHeader(responseHeaders, 'Location')) {
parseResult = {
location: getHeader(responseHeaders, 'Location')
}
} else if (hasHeader(responseHeaders, "Location")) {
parseResult = {
location: getHeader(responseHeaders, "Location"),
};
if (responseHeaders['x-ms-chunk-size'])
parseResult.chunkSize = parseInt(responseHeaders['x-ms-chunk-size']);
}
if (responseHeaders["x-ms-chunk-size"]) parseResult.chunkSize = parseInt(responseHeaders["x-ms-chunk-size"]);
}
}

@@ -374,2 +345,2 @@

return parseResult;
}
};

@@ -126,2 +126,7 @@ "use strict";

if (request.partitionId) {
ErrorHelper.stringParameterCheck(request.partitionId, "DynamicsWebApi." + functionName, "request.partitionId");
requestArray.push("partitionid='" + request.partitionId + "'");
}
if (request.downloadSize) {

@@ -137,2 +142,7 @@ ErrorHelper.stringParameterCheck(request.downloadSize, "DynamicsWebApi." + functionName, "request.downloadSize");

if (request.queryParams != null && request.queryParams.length) {
ErrorHelper.arrayParameterCheck(request.queryParams, "DynamicsWebApi." + functionName, "request.queryParams");
requestArray.push(request.queryParams.join("&"));
}
var prefer = buildPreferHeader(request, functionName, config);

@@ -139,0 +149,0 @@

{
"name": "dynamics-web-api",
"version": "1.7.6",
"description": "DynamicsWebApi is a Microsoft Dynamics CRM Web API helper library",
"keywords": [
"crm",
"cds",
"web-api",
"helper",
"d365",
"dynamics-crm",
"dynamics-365",
"common-data-service",
"dataverse",
"microsoft-dataverse",
"dynamics-crm-webapi",
"dynamics-crm-online"
],
"main": "lib/dynamics-web-api.js",
"types": "types/dynamics-web-api.d.ts",
"author": {
"name": "Aleksandr Rogov"
},
"devDependencies": {
"@peculiar/webcrypto": "^1.1.6",
"Base64": "^1.1.0",
"chai": "^4.3.0",
"coveralls": "^3.1.0",
"gulp": "^4.0.2",
"mocha": "^8.3.0",
"mocha-lcov-reporter": "^1.3.0",
"nock": "^11.9.1",
"nyc": "^15.1.0",
"rimraf": "^2.7.1",
"sinon": "^9.2.4",
"terser-webpack-plugin": "^5.1.1",
"webpack": "^5.24.1",
"webpack-cli": "^4.5.0",
"webpack-strip-block": "^0.3.0"
},
"dependencies": {
"http-proxy-agent": "^4.0.1",
"https-proxy-agent": "^5.0.0"
},
"license": "MIT",
"scripts": {
"test": "mocha tests/*-tests.js",
"test-coverage": "rimraf coverage && nyc npm test && nyc report --reporter=lcov",
"build": "rimraf dist && rimraf coverage && webpack",
"release-patch": "npm version patch -m \"Release v%s\"",
"release-minor": "npm version minor -m \"Release v%s\"",
"preversion": "npm test",
"version": "npm run build && git add -A dist",
"postversion": "git push && git push --tags",
"coveralls": "rimraf coverage && nyc npm test && nyc report --reporter=text-lcov | coveralls"
},
"repository": {
"type": "git",
"url": "https://github.com/AleksandrRogov/DynamicsWebApi.git"
},
"browser": {
"./lib/requests/http.js": "./lib/requests/xhr.js"
}
"name": "dynamics-web-api",
"version": "1.7.7",
"description": "DynamicsWebApi is a Microsoft Dynamics CRM Web API helper library",
"keywords": [
"crm",
"cds",
"web-api",
"helper",
"d365",
"dynamics-crm",
"dynamics-365",
"common-data-service",
"dataverse",
"microsoft-dataverse",
"dynamics-crm-webapi",
"dynamics-crm-online"
],
"main": "lib/dynamics-web-api.js",
"types": "types/dynamics-web-api.d.ts",
"author": {
"name": "Aleksandr Rogov"
},
"devDependencies": {
"@peculiar/webcrypto": "^1.4.0",
"Base64": "^1.1.0",
"chai": "^4.3.6",
"coveralls": "^3.1.1",
"gulp": "^4.0.2",
"mocha": "^10.0.0",
"mocha-lcov-reporter": "^1.3.0",
"nock": "^13.2.9",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"sinon": "^14.0.0",
"terser-webpack-plugin": "^5.3.6",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-strip-block": "^0.3.0"
},
"dependencies": {
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.1"
},
"license": "MIT",
"scripts": {
"test": "mocha tests/*-tests.js",
"test-coverage": "rimraf coverage && nyc npm test && nyc report --reporter=lcov",
"build": "rimraf dist && rimraf coverage && webpack",
"release-patch": "npm version patch -m \"Release v%s\"",
"release-minor": "npm version minor -m \"Release v%s\"",
"preversion": "npm test",
"version": "npm run build && git add -A dist",
"postversion": "git push && git push --tags",
"coveralls": "rimraf coverage && nyc npm test && nyc report --reporter=text-lcov | coveralls"
},
"repository": {
"type": "git",
"url": "https://github.com/AleksandrRogov/DynamicsWebApi.git"
},
"browser": {
"./lib/requests/http.js": "./lib/requests/xhr.js"
}
}

@@ -1,2 +0,2 @@

// Type definitions for dynamics-web-api v1.7.5
// Type definitions for dynamics-web-api v1.7.7
// Project: https://github.com/AleksandrRogov/DynamicsWebApi/

@@ -12,8 +12,8 @@ // Definitions by: Aleksandr Rogov https://github.com/AleksandrRogov/

/**
* Sets DynamicsWebApi configuration parameters.
*
* @param config - configuration object
* @example
dynamicsWebApi.setConfig({ webApiVersion: '9.1' });
*/
* Sets DynamicsWebApi configuration parameters.
*
* @param config - configuration object
* @example
dynamicsWebApi.setConfig({ webApiVersion: '9.1' });
*/
setConfig(config: DynamicsWebApi.Config): void;

@@ -42,3 +42,3 @@ /**

*/
createRequest<T = any>(request: DynamicsWebApi.CreateRequest): Promise<T>;
createRequest<T = any>(request: DynamicsWebApi.CreateRequest<T>): Promise<T>;
/**

@@ -63,3 +63,3 @@ * Sends an asynchronous request to create a new record.

*/
create<T = any>(object: Object, collection: string, prefer?: string | string[], select?: string[]): Promise<T>;
create<T = any>(object: T, collection: string, prefer?: string | string[], select?: string[]): Promise<T>;
/**

@@ -70,3 +70,3 @@ * Sends an asynchronous request to update a record.

*/
updateRequest<T = any>(request: DynamicsWebApi.UpdateRequest): Promise<T>;
updateRequest<T = any>(request: DynamicsWebApi.UpdateRequest<T>): Promise<T>;
/**

@@ -81,3 +81,3 @@ * Sends an asynchronous request to update a record.

*/
update<T = any>(key: string, collection: string, object: Object, prefer?: string | string[], select?: string[]): Promise<T>;
update<T = any>(key: string, collection: string, object: T, prefer?: string | string[], select?: string[]): Promise<T>;
/**

@@ -92,3 +92,9 @@ * Sends an asynchronous request to update a single value in the record.

*/
updateSingleProperty<T = any>(key: string, collection: string, keyValuePair: Object, prefer?: string | string[], select?: string[]): Promise<T>;
updateSingleProperty<T = any>(
key: string,
collection: string,
keyValuePair: { [key: string]: any },
prefer?: string | string[],
select?: string[]
): Promise<T>;
/**

@@ -128,3 +134,3 @@ * Sends an asynchronous request to delete a record.

*/
upsertRequest<T = any>(request: DynamicsWebApi.UpsertRequest): Promise<T>;
upsertRequest<T = any>(request: DynamicsWebApi.UpsertRequest<T>): Promise<T>;
/**

@@ -139,3 +145,3 @@ * Sends an asynchronous request to upsert a record.

*/
upsert<T = any>(key: string, collection: string, object: Object, prefer?: string | string[], select?: string[]): Promise<T>;
upsert<T = any>(key: string, collection: string, object: T, prefer?: string | string[], select?: string[]): Promise<T>;
/**

@@ -579,2 +585,4 @@ * 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

contentId?: string;
/**v.1.7.7+ A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */
partitionId?: string;
}

@@ -607,2 +615,4 @@

navigationPropertyKey?: string;
/**v.1.7.7+ A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */
partitionId?: string;
}

@@ -629,2 +639,4 @@

fieldName?: string;
/**v.1.7.7+ A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */
partitionId?: string;
}

@@ -653,2 +665,4 @@

userQuery?: string;
/**v.1.7.7+ A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */
partitionId?: string;
}

@@ -677,2 +691,6 @@

trackChanges?: boolean;
/**v.1.7.7+ A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */
partitionId?: string;
/**v.1.7.7+ Additional query parameters that either have not been implemented yet or they are parameter aliases for "$filter" and "$orderBy". Important! These parameters ARE NOT URI encoded! */
queryParams?: string[];
}

@@ -769,3 +787,3 @@

/**Multiple respone entities */
value?: T[];
value: T[];
oDataCount?: number;

@@ -781,2 +799,4 @@ oDataContext?: string;

interface RetrieveMultipleResponse<T> extends MultipleResponse<T> {
"@Microsoft.Dynamics.CRM.totalrecordcount"?: number;
"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded"?: boolean;
/**@odata.nextLink value */

@@ -783,0 +803,0 @@ oDataNextLink?: string;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc