AleksandrRogov / DynamicsWebApi

DynamicsWebApi is a Microsoft Dataverse Web API helper library for JavaScript & TypeScript
MIT License
268 stars 58 forks source link

Rewrite Configuration object to allow for more APIs (such as Search API) #139

Closed AleksandrRogov closed 1 year ago

AleksandrRogov commented 1 year ago

Configuration object for DynamicsWebApi needs to be rewritten to allow for configuration of Dataverse Search API.

webApiUrl and webApiVersion must be removed and marked as deprecated in v1. #136

The following properties should be added to a configuration object:

Property Name Type Description
dataApi ApiConfig Configuration object for Dataverse Web API. The name is based on the url path data.
searchApi ApiConfig Configuration object for Dataverse Search API. The name is based on the url path search
serverUrl String The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/

dataApi and searchApi should implement ApiConfig interface that has the following properties:

Property Name Type Description
path String A path to API, for example: "data" or "search"
version String API Version, for example: "1.0" or "9.2"

Each API configuration will have a default path and version:

dataApi

{
    path: "data",
    version: "9.2"
}

searchApi

{
    path: "search",
    version: "1.0"
}

Default configuration values will allow developers to omit initialization of all configuration properties if not needed. For example:

new DynamicsWebApi({
    serverUrl: "https://contoso.api.crm.dynamics.com/"
});

//requests to Data API will go to https://contoso.api.crm.dynamics.com/api/data/v9.2/
//requests to Search API will go to https://contoso.api.crm.dynamics.com/api/search/v1.0/

new DynamicsWebApi({
    serverUrl: "https://contoso.api.crm.dynamics.com/",
    dataApi: {
        version: "9.1"
    }
});

//requests to Data API will go to https://contoso.api.crm.dynamics.com/api/data/v9.1/
//requests to Search API will go to https://contoso.api.crm.dynamics.com/api/search/v1.0/

new DynamicsWebApi({
    serverUrl: "https://contoso.api.crm.dynamics.com/",
    searchApi: {
        path: "future-search"
    }
});

//requests to Data API will go to https://contoso.api.crm.dynamics.com/api/data/v9.2/
//requests to Search API will go to https://contoso.api.crm.dynamics.com/api/future-search/v1.0/

//and so on...