Skip to content

k.utils.ninjible ​

Site import and Lighthouse comparison task (Ninjible)

Execution ContextPrerequisitesTypical Use
KScript API, migration scriptsMigration service connectivity required; state is in-memory and lost on restartTriggering 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 / PropertyDescriptionReturns
createTask(url, rootDomain, orgName)Create a full site migration and optimization taskstring
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 IDNinjibleProgress | null

createTask() ​

Create a complete migration task (including optimization steps).

ParameterTypeRequiredDescription
urlstringYesOld site URL to migrate/optimize
rootDomainstringYesNew site root domain
orgNamestringYesOrganization 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.

ParameterTypeRequiredDescription
urlstringYesOld site URL to import
rootDomainstringYesNew 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.).

ParameterTypeRequiredDescription
taskIdstringYesTask 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 ​

PropertyTypeDescription
isDonebooleanWhether the task is complete
percentnumberCompletion percentage
oldUrl / newUrlstringOld and new site URLs
oldReportUrl / newReportUrlstringOld and new Lighthouse report URLs
devPassstringPreview access password
oldSiteScore / newSiteScoreLightHouseScoreContains 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;
}