k.utils.ninjible
Site import and Lighthouse comparison task (Ninjible)
| Execution Context | Prerequisites | Typical Use |
|---|---|---|
| KScript API, migration scripts | Migration service connectivity required; state is in-memory and lost on restart | Triggering site migration tasks and polling old/new Lighthouse scores |
k.utils.ninjible creates remote site migration/optimization tasks and queries their progress.
Scope Note
This module is intended for Kooboo site migration and Lighthouse comparison tasks; task state is stored in process memory and resets on server restart.
Quick Start
js
k.api.post("importSite", () => {
const taskId = k.utils.ninjible.createImportTask("https://old.example.com", "new.example.com")
const status = k.utils.ninjible.getStatus(taskId)
return { taskId, percent: status ? status.percent : 0 }
})Quick Reference
| Method / Property | Description | Returns |
|---|---|---|
createTask(url, rootDomain, orgName) | Create a full site migration and optimization task | string |
createImportTask(url, rootDomain) | Import a site and run speed optimization under the current site's organization (skips Lighthouse audits) | string |
getStatus(taskId) | Poll NinjibleProgress status and scores by task ID | NinjibleProgress | null |
createTask()
Create a complete migration task (including optimization steps).
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Old site URL to migrate/optimize |
rootDomain | string | Yes | New site root domain |
orgName | string | Yes | Organization name used to determine task ownership |
Returns: string, the task ID.
js
const taskId = k.utils.ninjible.createTask(oldUrl, rootDomain, orgName)createImportTask()
Import a site and run speed optimization (image WebP conversion, CSS optimization, and browser caching) under the current site's organization, while skipping old and new Lighthouse report audits.
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Old site URL to import |
rootDomain | string | Yes | New site root domain |
Returns: string, the task ID.
js
const taskId = k.utils.ninjible.createImportTask("https://old.example.com", "new.example.com")getStatus()
Query NinjibleProgress by taskId (isDone, percent, oldUrl, newUrl, Lighthouse scores, etc.).
| Parameter | Type | Required | Description |
|---|---|---|---|
taskId | string | Yes | Task ID returned by createTask() or createImportTask() |
Returns: NinjibleProgress | null.
js
const status = k.utils.ninjible.getStatus(taskId)
return {
percent: status ? status.percent : null,
done: status ? status.isDone : false,
newUrl: status ? status.newUrl : null
}NinjibleProgress and LightHouseScore
| Property | Type | Description |
|---|---|---|
isDone | boolean | Whether the task is complete |
percent | number | Completion percentage |
oldUrl / newUrl | string | Old and new site URLs |
oldReportUrl / newReportUrl | string | Old and new Lighthouse report URLs |
devPass | string | Preview access password |
oldSiteScore / newSiteScore | LightHouseScore | Contains performance, sEO (note casing), accessibility, and bestPractices |
TypeScript Definitions
ts
interface Ninjible {
createTask(url: string, rootDomain: string, OrgName: string): string;
createImportTask(url: string, rootDomain: string): string;
getStatus(taskId: string): NinjibleProgress;
}
interface NinjibleProgress {
isDone: boolean;
percent: number;
oldUrl: string;
oldReportUrl: string;
devPass: string;
newUrl: string;
newReportUrl: string;
oldSiteScore: LightHouseScore;
newSiteScore: LightHouseScore;
}
interface LightHouseScore {
performance: number;
sEO: number;
accessibility: number;
bestPractices: number;
}