LEAP Host SDK is a TypeScript library that helps your LEAP apps communicate easily with LEAP client applications.
This library should be installed as an npm package. We use semantic versioning so the best way to stay up-to-date without backward compatibility concern is to accept minor releases:
npm i @leapdev/leap-host
Auth token, firmId and userId will no longer be provided in the context after you init the sdk, you can get the auth token by calling the getRefreshedAccessToken() method and get the firmId and userId from getDecodedRefreshedAccessToken().
In order to have all the features supported, please develop with the latest LEAP desktop 2.3 or above
The first thing you have to do is to initialise the SDK
import { LeapHostSdkFactory } from '@leapdev/leap-host';
const sdk = LeapHostSdkFactory.getInstance();
if (!!sdk) {
await sdk.init('LEAP auth clientId');
// IMPORTANT: please make sure you are using the correct clientId we provide for your app
}
This init
function returns a Promise
. We recommend that you do this initialisation once and cache the promise result in memory.
By awaiting the promise, you then have access to methods that perform actions in the LEAP client applications. Please refer to the API reference for all supported methods.
A LEAP app needs to know the context of where its being loaded, e.g. the matterId where it is loaded, which record is being selected (if the current page in LEAP is a list), etc. The LEAP app is expected to retrieve the context object from the hosting LEAP client application. A connection between the LEAP client application and LEAP app is assigned a unique guid. The LEAP app can access this value via "appSessionId" property received.
The LEAP Host SDK abstracts the context retrieval process by presenting a unified API to the LEAP app. By calling the init function, the LEAP app will have access to the context object as follow.
import { LeapHostSdkFactory } from '@leapdev/leap-host';
const sdk = LeapHostSdkFactory.getInstance();
if (!!sdk) {
await sdk.init('LEAP auth clientId');
console.log(sdk.leapContext);
}
A LEAP app often needs to call the LEAP API Gateway services. To do so, you will need to init the sdk first then call the method below
// for best practise, just call this method whenever you need to use the access token, caching it is not recommeded
const accessToken = await sdk.getRefreshedAccessToken();
// or if you want to get the claims in the token you can go
const decodedAccessToken = await sdk.getDecodedRefreshedAccessToken();
A LEAP client applications (LEAP Desktop / Web / Mobile) accepts certain messages from LEAP apps and act upon them. For example, they can open a document or show a message box.
The LEAP Host SDK facilitates this process by exposing a set of semantic functions through which the LEAP app can invoke.
await sdk.init();
// open a message box in LEAP
sdk.system.alert({ message: 'Hello, world' });
// open a matter
sdk.matter.openMatter(openMatterRequest);
// close the app
sdk.system.close();
createTimeEntryV2(request: CreateTimeEntryRequest): Promise<CreateTimeEntryResponse>;
createFeeEntryV2(request: CreateFeeEntryRequest): Promise<CreateFeeEntryResponse>;
createCostRecoveryV2(request: CreateCostRecoveryEntryRequest): Promise<CreateCostRecoveryResponse>;
//Request example:
const request = {
"matterId":"c2b1cbde-77ec-2642-91d9-09191e5258c6",
"appSessionId":"1fa55cbb-7b02-a546-94a2-8986be7fce5b"
};
const response = await sdk.accounting.createCostRecoveryV2(request);
createInvoiceV2(request: CreateInvoiceRequest): Promise<CreateInvoiceResponse>;
createOfficeReceiptV2(request: CreateOfficeReceiptRequest): Promise<CreateOfficeReceiptResponse>;
createOfficePaymentV2(request: CreateOfficePaymentRequest): Promise<CreateOfficePaymentResponse>;
//Request example:
const request = {
"matterId":"c2b1cbde-77ec-2642-91d9-09191e5258c6",
"appSessionId":"1fa55cbb-7b02-a546-94a2-8986be7fce5b"
};
const response = await sdk.accounting.createOfficePaymentV2(request);
createOfficePaymentRequestV2(request: CreateNewOfficePaymentRequestRequest): Promise<CreateNewOfficePaymentRequestResponse>;
createTrustPaymentRequestV2(request: CreateNewTrustPaymentRequestRequest): Promise<CreateNewTrustPaymentRequestResponse>;
createOfficeJournalV2(request: CreateOfficeJournalRequest): Promise<CreateOfficeJournalResponse>;
createTrustReceiptV2(request: CreateTrustReceiptRequest): Promise<CreateTrustReceiptResponse>;
createTrustPaymentV2(request: CreateTrustPaymentRequest): Promise<CreateTrustPaymentResponse>;
createOfficeJournalV2(request: CreateOfficeJournalRequest): Promise<CreateOfficeJournalResponse>;
createTrustToOfficeV2(request: CreateTrustToOfficeRequest): Promise<CreateTrustToOfficeResponse>;
reloadFinancialSummary(request: ReloadFinancialSummaryRequest): void;
reloadTimeFeeList(request: ReloadTimeFeeListRequest): void;
reloadOfficeLedger(request: ReloadOfficeLedgerRequest): void;
reloadAnticipatedPaymentList(request: ReloadAnticipatedPaymentListRequest): void;
reloadCostRecoveryList(request: ReloadCostRecoveryListRequest): void;
//Request example:
const request = {
"matterId":"c2b1cbde-77ec-2642-91d9-09191e5258c6",
"appSessionId":"1fa55cbb-7b02-a546-94a2-8986be7fce5b"
};
sdk.accounting.reloadCostRecoveryList(request);
reloadTrustLedger(request: ReloadTrustLedgerRequest): void;
reloadControlledMoneyList(request: ReloadControlledMoneyListRequest): void;
reloadPowerMoneyList(request: ReloadPowerMoneyListRequest): void;
reloadTransitMoneyList(request: ReloadTransitMoneyListRequest): void;
openFee(request: OpenFeeRequest): void;
evaluatePaths(request: EvaluatePathsRequest): Promise<PathResult[]>;
//Request example:
const request = {
"executionContext": {
"matterGUID": "a4a9a42d-2dd8-48c4-bf06-b213369a5c84"
},
"paths": ["matter.clientList.{__id,__className,__fileOrder,__description,personList}", "matter.fileNumber"]
};
sdk.calc.evaluatePaths(request)
.then(response =>{
//handle the response here
});
selectCard(request?: SelectCardRequest): Promise<Card[]>;
createCard(): Promise<CreatedCard[]>;
openCard(request: OpenCardRequest): void;
composeEmail(request: CreateEmailRequest): void;
createAppointment(request: CreateAppointmentRequest): void;
//Request example:
const request = {
"matterId":"c2b1cbde-77ec-2642-91d9-09191e5258c6",
"startDate": "2020-10-21T05:12:46.472Z",
"endDate": "2020-10-22T05:13:46.472Z",
"attachments":[],
"requiredAttendees":[],
"optionalAttendees":[]
};
sdk.communication.createAppointment(request);
createTask(request: CreateTaskRequest): void;
//Request example:
const request = {
"matterId":"c2b1cbde-77ec-2642-91d9-09191e5258c6",
"startDate":"2020-10-21T00:00:00.000Z",
"dueDate":"2020-10-22T00:00:00.000Z"
};
sdk.communication.createTask(request);
previewDocument(request: PreviewDocumentRequest): void;
previewPrecedent(request: PreviewPrecedentRequest): void;
editPrecedent(request: EditPrecedentRequest): void;
selectPrecedent(request: SelectPrecedentRequest): Promise<SelectPrecedentResponse>;
createDocumentFromContainer(request: CreateDocumentFromContainerRequest): void;
createDocumentFromPrecedent(request: CreateDocumentFromPrecedentRequest): void;
openDocument(request: OpenDocumentRequest): void;
const request = {
"matterId":"c2b1cbde-77ec-2642-91d9-09191e5258c6",
"documentId":"ba5e2173-e6bc-47b4-9280-787f78454e2b",
"appSessionId":"b90402b8-c7cb-435b-b1fc-8bbcb1d49934"
};
sdk.document.openDocument(request);
reloadDocumentList(request: ReloadDocumentListRequest): void;
shareDocuments(request: ShareDocumentsRequest): void;
shareFolder(request: ShareFolderRequest): void;
shareOfficeStatement(request: ShareOfficeStatementRequest): void;
shareTrustStatement(request: ShareTrustStatementRequest): void;
openTable(request: OpenTableRequest): void;
openMatter(request: OpenMatterRequest): void;
//Request example:
const request = {
"matterId":"c2b1cbde-77ec-2642-91d9-09191e5258c6",
"appSessionId":"1fa55cbb-7b02-a546-94a2-8986be7fce5b"
};
sdk.matter.openMatter(request);
selectMatter(request?: SelectMatterRequest): Promise<Matter[]>;
selectStaff(request?: SelectStaffRequest): Promise<Staff[]>;
shareDocument(request: ShareDocumentRequest): void;
shareMatter(request: ShareMatterRequest): void;
shareMatter(request: RequestCallbackRequest): void;
selectPerson(request: SelectPersonRequest): Promise<Person[]>;
openPerson(request: OpenPerson): void;
reloadDocumentRegisterList(request: ReloadDocumentRegisterListRequest): void;
reloadPowerEstateList(request: ReloadPowerEstateListRequest): void;
getLists(request: GetListsRequest): Promise<SchemaResponse<SchemaList[]>>;
customiseList(request: CustomiseListRequest): Promise<CustomiseListResponse>;
openTwitter(request: BaseRequest): void;
close(): void;
hide(): void;
wait(request?: MessageRequest): void;
resume(): void;
alert(): void;
error(): void;
openDialogV2(request: DialogRequest): Promise<system.DialogButtonType>;
openUrl(config: BrowserConfig): void;
//Request example:
const config = {
"url": "https://app.test.bylawyers.com.au/",
"openExternal": false,
"useNativeLoading": false
"width": 900,
"height": 500,
"minWidth": 800,
"minHeight": 400,
"maxWidth": 1000,
"maxHeight": 600,
"closeHandler": "jsFunction(parameter)",
"fixedWindowSize": false,
"independentWindow": false,
"windowTitle": "Good day"
};
sdk.system.openUrl(config);
getSystemInfo(): void;
setWindowTitle(request: SetWindowTitleRequest): void;
registerHostMessageHandler('onBeforeClose', () => {
//sdk.system.cancelClose();
//your logic goes here
//sdk.system.close();
});
send(request: object, hasResponse?: boolean): Promise<any>;
Notify the host system when your app has finished loading (to avoid having different loaders from LEAP and your app)
finishLoading(): void;