LeadSquared Developer Centre

ON THIS PAGE

Lapps SDK


Overview

Developers require LeadSquared administrator access to create and test Lapps. The values of confidential settings (e.g., access keys, secret keys, FTP credentials, SQL server credentials, etc.) and critical operations like unpublishing and deleting Lapps are made available through administrator access.

The Lapps SDK helps mitigate security risks by enabling developers to create, test, and publish Lapps (on their local machines), without administrator access to your LeadSquared account. It grants developers limited access to Lapps functionality through distinct access levels (Administrator, Developer – Publisher, Developer) and token-based authorization.

The Lapps SDK package mocks all the features available on the online platform to enable quick and easy offline development. This guide documents the features available in the Lapps SDK, and how they work.

 

Developer Access Levels

The following access levels and permissions are available –

Create Lapp Upload Code Publish to Test Publish to Live
Admin Yes Yes Yes Yes
Developer – Publisher Yes Yes Yes No
Developer Yes Yes No No

The LeadSquared admin user must generate the token for each access level from the Manage Lapps page on the LeadSquared application –

  1. On the main menu, navigate to Apps>Manage Lapps.
  2. On the panel on the right, under Global, click SDK Developer Tokens.
  3. Select the Access Level, and enter a user name (max 100 characters, only permitted special characters are dot “.”, comma “,” and hyphen “-“).
  4. Click the Generate SDK Token alongside each access level. Click the view icon icon to view the token and click copy icon to copy the token.

LeadSquared Lapps

Note: The generated token is valid for only 30 days. Once expired, the admin must generate a new token.

 

Installation

The easiest way to install lslapp is from NPM. Open a command prompt and run the following command to install the lslapp library globally –

$ npm install -g lslapp

Note:

  • This package runs locally on Node version>16.x. It’s advised to make the target node version 16.x specifically, as deployment is done on the same version.
  • Linux users must not install the package with sudo. To change the permission to the current user just run $ sudo chown -R $(whoami) ~/.npm

 

Using this Library

 

Initialize a New Lapp

In your project folder, enter the following command –

$ lslapp init

Now enter your Lapp name (e.g., first-lapp) –

$ Your Lapp name: first-lapp

Note: The only permitted special characters are underscore “_” and hyphen “-“. The name cannot start with special characters. If not followed, the lslapp save operation (Create and Upload Lapp Code for Deployment) will fail.

A Lapp template is generated. Navigate to main.js and write your code.

 

Run a Lapp

Navigate inside the directory of the Lapp and enter the following command  –

$ cd first-lapp

Enter the following command to run and test your Lapp locally –

$ lslapp run

The Lapp executes locally and returns a response.

 

Pack a Lapp for Deployment

Ensure you’re inside the Lapp’s root folder. Run the following command to prepare a deployable zip file in the deliverables folder –

$ lslapp pack

 

Configure Tenant Profile

Using the configure command, you can create multiple tenant profiles with various access levels. You’ll be prompted to enter all input values.

$ lslapp configure

You will be prompted to enter

  • Profile Name – Define the profile name. We suggest you enter a profile name in the following convention so it is easy to remember and re-use – <orgcode>+<developer access level> (e.g., 1234Admin)
  • Orgcode – LeadSquared organization code (e.g., 1234). To find your orgcode, see How to Find My LeadSquared Orgcode.
  • Region – You may pass 1, 11, 21, 31, 41, or 51. 1 denotes Singapore | 11 denotes U.S.A | 21 denotes India | 31 denotes Ireland | 41 denotes Sydney | 51 denotes Jakarta
  • Token – Pass the token generated from the Lapps UI.

You can also simply run lslapp. It will prompt all available commands.

$ lslapp

 

Create and Upload a Lapp Code for Deployment

Pass the command line parameters -orgcode -region -token. You may also pass these parameters as -o, -r and -t.

E.g., lslapp save -orgcode 1234 -region 1 -token asdfghijkl1234

Alternatively, if you’ve configured a profile use -profile or -p.

E.g., lslapp save -profile mytenant1234

Note:

  • If the Lapp Id doesn’t exist in the config.json file, the command creates a Lapp and uploads the code.
  • If the Lapp Id exists in config.json, it packs and uploads the code to the Lapp.

 

Deploy/Publish a Lapp

Publishes a Lapp to the test environment.

Pass the command line parameters -orgcode -region -token. You may also pass these parameters as -o, -r and -t.

E.g., lslapp publish -orgcode 1234 -region 1 -token asdfghijkl1234

Alternatively, if you’ve configured a profile use -profile or -p.

E.g., lslapp publish -profile mytenant1234

Note: Only Admins and Developer – Publisher can publish a Lapp to the test environment.

 

Publish a Lapp to Live Environment

Publishes a Lapp to the Live environment.

$ lslapp publish -profile profilename -live <anystringvalue>

E.g., lslapp publish -profile mytenant1234 -live true

Note: Only Admins can publish a Lapp to the live environment.

 

Writing Code in Lapps

The Lapps SDK package mocks all the features available on the online platform. For more information, see

On this page

© 2022 by MarketXpander Services Pvt Ltd. All Rights Reserved.