hac-client
The hac-client
is a utility to interact with the Hybris Administration Console (HAC) programmatically. It provides methods to authenticate, execute flexible search queries, and perform other administrative tasks.
Installing
Using npm:
$ npm install @e2y/hac-client
Usage
const { HACClient } = require('@e2y/hac-client');
const baseUrl = 'https://localhost:9002/hac';
const credentials = { username: 'admin', password: '1234' };
const hacClient = HACClient.create(baseUrl, credentials);
API
Creates a new instance of HACClient and authenticates with the provided credentials.
const hacClient = await HACClient.create(baseUrl, { username, password })
Executes a flexible search query and returns the results.
await hacClient.executeFlexibleSearch(query)
Example
import { FlexibleSearchResponse, HACClient } from '@e2y/hac-client';
const baseUrl: string = 'https://localhost:9002/hac';
const credentials = {username: 'admin', password: '1234'};
async function main() {
const hacClient: HACClient = await HACClient.create(baseUrl, credentials);
const query: string = 'SELECT * FROM Product';
const response: FlexibleSearchResponse = await hacClient.executeFlexibleSearch(query);
console.log('Flexible Search Response:', response);
}
Running cron jobs
const cronJobCode: string = 'testCronJob';
const response = await hacClient.runCronJob(cronJobCode);
For local development fetch does not allow https insecure SSL certs or http connection to avoid issues set NODE_TLS_REJECT_UNAUTHORIZED=0
in your env parameters