2021-08-17 03:15:14 +03:00
|
|
|
import { Poke, Scry } from '../lib';
|
2021-09-29 11:33:47 +03:00
|
|
|
import { Vats, Vat } from './types';
|
2021-08-17 03:15:14 +03:00
|
|
|
|
|
|
|
export const getVats: Scry = {
|
|
|
|
app: 'hood',
|
|
|
|
path: '/kiln/vats'
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Install a foreign desk
|
|
|
|
*/
|
|
|
|
export function kilnInstall(
|
|
|
|
ship: string,
|
|
|
|
desk: string,
|
|
|
|
local?: string
|
|
|
|
): Poke<any> {
|
|
|
|
return {
|
|
|
|
app: 'hood',
|
|
|
|
mark: 'kiln-install',
|
|
|
|
json: {
|
|
|
|
ship,
|
|
|
|
desk,
|
|
|
|
local: local || desk
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Uninstall a desk
|
|
|
|
*/
|
|
|
|
export function kilnUninstall(
|
|
|
|
desk: string
|
|
|
|
): Poke<any> {
|
|
|
|
return {
|
|
|
|
app: 'hood',
|
|
|
|
mark: 'kiln-uninstall',
|
|
|
|
json: desk
|
|
|
|
};
|
|
|
|
}
|
2021-08-23 07:37:36 +03:00
|
|
|
|
|
|
|
export function kilnSuspend(
|
|
|
|
desk: string
|
|
|
|
): Poke<any> {
|
|
|
|
return {
|
|
|
|
app: 'hood',
|
|
|
|
mark: 'kiln-suspend',
|
|
|
|
json: desk
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function kilnRevive(
|
|
|
|
desk: string
|
|
|
|
): Poke<any> {
|
|
|
|
return {
|
|
|
|
app: 'hood',
|
|
|
|
mark: 'kiln-revive',
|
|
|
|
json: desk
|
|
|
|
};
|
|
|
|
}
|
2021-08-25 02:17:12 +03:00
|
|
|
|
2021-09-07 07:46:44 +03:00
|
|
|
export function kilnBump(force = false, except = [] as string[]) {
|
|
|
|
return {
|
|
|
|
app: 'hood',
|
|
|
|
mark: 'kiln-bump',
|
|
|
|
json: {
|
|
|
|
force,
|
|
|
|
except
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2021-08-25 10:36:38 +03:00
|
|
|
|
2021-09-14 02:47:51 +03:00
|
|
|
export function kilnPause(desk: string) {
|
|
|
|
return {
|
|
|
|
app: 'hood',
|
|
|
|
mark: 'kiln-pause',
|
|
|
|
json: desk
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function kilnResume(desk: string) {
|
|
|
|
return {
|
|
|
|
app: 'hood',
|
|
|
|
mark: 'kiln-resume',
|
|
|
|
json: desk
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-08-25 02:17:12 +03:00
|
|
|
export const scryLag: Scry = ({ app: 'hood', path: '/kiln/lag' });
|
|
|
|
|
|
|
|
export function getBlockers(vats: Vats): string[] {
|
2021-08-25 10:36:38 +03:00
|
|
|
const blockers: string[] = [];
|
|
|
|
const base = vats?.base;
|
2021-08-25 02:17:12 +03:00
|
|
|
if(!base) {
|
|
|
|
return blockers;
|
|
|
|
}
|
2021-09-21 07:11:58 +03:00
|
|
|
const blockedOn = base.arak.rail?.next?.[0]?.weft?.kelvin;
|
2021-08-25 02:17:12 +03:00
|
|
|
if(!blockedOn) {
|
|
|
|
return blockers;
|
|
|
|
}
|
2021-11-09 03:44:04 +03:00
|
|
|
|
|
|
|
Object.entries(vats)
|
|
|
|
.filter(([desk]) => desk !== 'base')
|
|
|
|
.forEach(([desk, vat]) => {
|
|
|
|
// assuming only %zuse
|
|
|
|
const woofs = vat.arak.rail?.next || [];
|
|
|
|
const kelvins = woofs.map(n => n.weft.kelvin);
|
|
|
|
if(!(kelvins.includes(blockedOn))) {
|
|
|
|
blockers.push(desk);
|
|
|
|
}
|
|
|
|
});
|
2021-08-25 02:17:12 +03:00
|
|
|
|
|
|
|
return blockers;
|
|
|
|
}
|
2021-09-29 11:33:47 +03:00
|
|
|
|
|
|
|
export function getVatPublisher(vat: Vat): string | undefined {
|
2021-09-29 13:01:30 +03:00
|
|
|
if (vat.arak.rail) {
|
2021-09-29 11:33:47 +03:00
|
|
|
const { rail } = vat.arak;
|
2021-09-29 13:01:30 +03:00
|
|
|
return (rail?.publisher || rail?.ship || undefined);
|
2021-09-29 11:33:47 +03:00
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|