Generate the Typescript proxy for Store Commerce

Completed

The Commerce proxy abstracts the interface between the Retail Server and Commerce runtime (CRT).

For example, you can create a new entity and some business logic as request/response operations in CRT, and you can add a new Retail Server API to expose that entity and those request/response operations. Now, you want to access the entity and the request/response operations in the Store Commerce to create some client logic.

You can manually create all entities and request/response metadata in the Store Commerce, and you can access the Retail Server by using the correct parameters. The Commerce proxy reduces this effort by automatically generating the proxy for all custom entities and request/response operations that are added in Retail Server API.

The proxy tool generates the required interface and all required metadata and then abstracts the actual implementation. In that way, you can include the files in the extension projects and access the Retail Server APIs and entities by using the metadata and interface that are generated.

To generate the Typescript proxy for Store Commerce, follow these steps:

  1. Open the sample proxy template project from \RetailSDK\Code\SampleExtensions\TypeScriptProxy\TypeScriptProxy.Extensions.StoreHoursSample\Proxies.TypeScriptProxy.Extensions.StoreHoursSample.csproj in Visual Studio. Rename it, if necessary.

  2. Add the Retail Server extension project as a project reference project to this proxy template project. Remove the existing StoreHoursSample project reference.

  3. Right-click Proxies.TypeScriptProxy.Extensions.StoreHoursSample.csproj and then select Edit Proxies.TypeScriptProxy.Extensions.StoreHoursSample.csproj.

  4. Under the RetailServerExtensionAssemblies node, specify your Retail Server extension assembly name. The following example shows how to add the assembly name.

    <ItemGroup>
        <RetailServerExtensionAssemblies Include="..\..\RetailServer\Extensions.Sample\bin\$(Configuration)\net461\$(AssemblyNamePrefix).RetailServer.Extension.Sample.dll" />
    </ItemGroup>
    
  5. Under the Copy node, update the DestinationFolder path to your Store Commerce extension folder so that generated proxy files are copied to the POS Extension folder automatically. The generated proxy files will also be copied to \RetailSDK\Code\SampleExtensions\TypeScriptProxy\TypeScriptProxy.Extensions.StoreHoursSample\DataService. The following example shows how to update the path.

    <Copy SourceFiles="@(GeneratedDataServiceContracts)" DestinationFolder="$(SdkRootPath)\POS\Extensions\Sample\DataService" SkipUnchangedFiles="true" />
    
  6. After the changes are complete, build the proxy project to generate the Typescript proxy files. When the build has completed, the proxy files will be available in the \RetailSDK\Code\SampleExtensions\TypeScriptProxy\TypeScriptProxy.Extensions.StoreHoursSample\DataService folder and the folder that is specified in the Copy command. The path and folder path can vary based on the folder structure.

For more information, see Create a new Retail Server extension API.