🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

@shipengine/connect-rendering-client

Package Overview
Dependencies
Maintainers
28
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shipengine/connect-rendering-client

Rendering Service client

npmnpm
Version
1.1.0
Version published
Weekly downloads
9
-40%
Maintainers
28
Weekly downloads
 
Created
Source

TypeScript Library

The @shipengine/connect-rendering-client provides developers with the ability to access the rendering capabilities.

Example

This example shows you how to render the documents within the CreateLabel method.

import { join } from 'path';
import { CreateLabelRequest, CreateLabelResponse } from '@shipengine/connect-carrier-api';
import { GetDocuments } from '@shipengine/connect-rendering-client';

export const CreateLabel = async (request: CreateLabelRequest): Promise<CreateLabelResponse> => {
    const templatePath = join(__dirname, '../../assets/templates/dummy_carrier.carrier')
    return await GetDocuments(request, templatePath);
}

If you prefer to use the template with multiple documents, it is possible to select the document to be rendered by its name. In the following example, two documents are selected.

return await GetDocuments(request, templatePath, ['standard_label', 'additional_label']);

Usage:

  • Your app must contain a documents template file. The file must be in json format with snake case naming convention. Look at Documents Designer tool. The carrier metadata must specify the local path to the template file:
 DocumentTemplate: join(__dirname, "../../../assets/carrier_api_code.carrier"),
  • The environment variable RENDERING_HOST has to be set. For modules deployed in dev environment, the app developer must run the following command prior to connect publish:
connect env:set RENDERING_HOST http://connect-rendering-prod.kube.seplocal.com

In order to use Rendering in higher environment, the app developer must add the following environment variable to module's helm file:

RENDERING_HOST: "#{RENDERING_HOST}"

The value will be substituted by Octopus, according to environment where the module is deployed to.

Customs documents

Generic customs documents: customs form (CN22, CN23), commercial invoice (CI) are supported out of the box. Developer decides what kind of document should be generated by selecting document names. Customs documents are available in three languages: English (EN), German (DE), French (FR).

This example shows how to generate commercial invoice and customs form in French.

import { CreateLabelRequest, CreateLabelResponse } from '@shipengine/connect-carrier-api';
import { GetCustoms } from '@shipengine/connect-rendering-client';

export const CreateLabel = async (request: CreateLabelRequest): Promise<CreateLabelResponse> => {
    return await GetCustoms(request, ['CI', 'CN22'], 'FR');
}

By default, customs documents are generated in English.

return await GetCustoms(request, ['CI', 'CN23']);

Building

From the repository root, navigate to this package directory.

Install dependencies yarn

Build yarn build

Keywords

native-rendering

FAQs

Package last updated on 04 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts