File tree Expand file tree Collapse file tree 4 files changed +28
-15
lines changed Expand file tree Collapse file tree 4 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010 count ,
1111 countAll ,
1212 create ,
13+ createAttribute ,
1314 createEntity ,
1415 deleteRecord ,
1516 disassociate ,
@@ -277,19 +278,7 @@ export class DynamicsWebApi {
277278 * @param request - An object that represents all possible options for a current request.
278279 * @returns {Promise } D365 Web Api Response
279280 */
280- createAttribute = < T = any > ( request : CreateAttributeRequest ) : Promise < T > => {
281- ErrorHelper . parameterCheck ( request , "DynamicsWebApi.createAttribute" , "request" ) ;
282- ErrorHelper . parameterCheck ( request . data , "DynamicsWebApi.createAttribute" , "request.data" ) ;
283- ErrorHelper . keyParameterCheck ( request . entityKey , "DynamicsWebApi.createAttribute" , "request.entityKey" ) ;
284-
285- const internalRequest = copyRequest ( request ) ;
286- internalRequest . collection = "EntityDefinitions" ;
287- internalRequest . functionName = "retrieveEntity" ;
288- internalRequest . navigationProperty = "Attributes" ;
289- internalRequest . key = request . entityKey ;
290-
291- return this . create ( < CreateRequest > internalRequest ) ;
292- } ;
281+ createAttribute = < T = any > ( request : CreateAttributeRequest ) : Promise < T > => createAttribute ( request , this . #client) ;
293282
294283 /**
295284 * Sends an asynchronous request to update an attribute.
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type { InternalRequest } from "../types";
55import { convertToFileBuffer , copyRequest , downloadChunkSize } from "../utils/Utility" ;
66import { LIBRARY_NAME } from "./constants" ;
77
8- const FUNCTION_NAME = "deleteRecord " ;
8+ const FUNCTION_NAME = "downloadFile " ;
99const REQUEST_NAME = `${ LIBRARY_NAME } .${ FUNCTION_NAME } ` ;
1010
1111const downloadFileChunk = async (
Original file line number Diff line number Diff line change @@ -23,4 +23,5 @@ export * from "./downloadFile";
2323export * from "./metadata/createEntity" ;
2424export * from "./metadata/updateEntity" ;
2525export * from "./metadata/retrieveEntity" ;
26- export * from "./metadata/retrieveEntities" ;
26+ export * from "./metadata/retrieveEntities" ;
27+ export * from "./metadata/createAttribute" ;
Original file line number Diff line number Diff line change 1+ import type { IDataverseClient } from "../../client/dataverse" ;
2+ import type { CreateAttributeRequest , CreateRequest } from "../../dynamics-web-api" ;
3+ import { copyRequest } from "../../utils/Utility" ;
4+ import { create } from "../create" ;
5+ import { LIBRARY_NAME } from "../constants" ;
6+ import { ErrorHelper } from "../../helpers/ErrorHelper" ;
7+
8+ const FUNCTION_NAME = "createAttribute" ;
9+ const REQUEST_NAME = `${ LIBRARY_NAME } .${ FUNCTION_NAME } ` ;
10+
11+ export const createAttribute = < T = any > ( request : CreateAttributeRequest , client : IDataverseClient ) : Promise < T > => {
12+ ErrorHelper . parameterCheck ( request , REQUEST_NAME , "request" ) ;
13+ ErrorHelper . parameterCheck ( request . data , REQUEST_NAME , "request.data" ) ;
14+ ErrorHelper . keyParameterCheck ( request . entityKey , REQUEST_NAME , "request.entityKey" ) ;
15+
16+ const internalRequest = copyRequest ( request ) ;
17+ internalRequest . collection = "EntityDefinitions" ;
18+ internalRequest . functionName = FUNCTION_NAME ;
19+ internalRequest . navigationProperty = "Attributes" ;
20+ internalRequest . key = request . entityKey ;
21+
22+ return create ( internalRequest as CreateRequest , client ) ;
23+ } ;
You can’t perform that action at this time.
0 commit comments