@urbit/api: add kiln bindings

This commit is contained in:
Liam Fitzgerald 2021-08-17 10:15:14 +10:00
parent 2d0d09d891
commit da4ee2189e
4 changed files with 197 additions and 1 deletions

View File

@ -0,0 +1,2 @@
export * from './lib';
export * from './types';

38
pkg/npm/api/hood/lib.ts Normal file
View File

@ -0,0 +1,38 @@
import { Poke, Scry } from '../lib';
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
};
}

154
pkg/npm/api/hood/types.ts Normal file
View File

@ -0,0 +1,154 @@
/**
* A pending commit, awaiting a future kelvin version
*/
interface Woof {
aeon: number;
weft: Weft;
}
interface Rein {
/**
* Agents not in manifest that should be running
*/
add: string[];
/**
* Agents in manifest that should not be running
*/
sub: string[];
}
/**
* A tracker of a foreign {@link Vat}
*
*/
export interface Arak {
/**
* Ship of foreign vat
*/
ship: string;
/**
* Desk of foreign vat
*/
desk: string;
/**
* Aeon (version number) that we currently have synced
*/
aeon: number;
next: Woof[];
rein: Rein;
}
/**
* A component's kelvin version
*/
export interface Weft {
/**
* Name of the component
*
* @remarks
* Usually %zuse, %hoon, or %lull
*/
name: string;
/**
* Kelvin version
*
*/
kelvin: number;
}
export interface KilnDiffBlock {
block: {
desk: string;
arak: Arak;
weft: Weft;
blockers: string[];
};
}
export interface KilnDiffReset {
reset: {
desk: string;
arak: Arak;
};
}
export interface KilnDiffMerge {
merge: {
desk: string;
arak: Arak;
};
}
export interface KilnDiffMergeSunk {
'merge-sunk': {
desk: string;
arak: Arak;
tang: string;
};
}
export interface KilnDiffMergeFail {
'merge-fail': {
desk: string;
arak: Arak;
tang: string;
};
}
export type KilnDiff =
| KilnDiffBlock
| KilnDiffReset
| KilnDiffMerge
| KilnDiffMergeSunk
| KilnDiffMergeFail;
/**
* Cases for revision
*
*/
interface Cass {
/**
* Revision number
*/
ud: number;
/**
* Timestamp of revision, as unix timestamp
*
* @remarks
* If \@da is outside valid positive unix timestamp, value will be zero
*/
da: string;
}
/**
* A local desk installation
*/
export interface Vat {
/**
* Desk that this Vat describes
*/
desk: string;
/**
* Hash of the desk, rendered as `@uv`
*
* @remarks
* Equivalent to
* ```hoon
* .^(@uv %cz /=desk=)
* ```
*/
hash: string;
/**
* Current revision
*/
cass: Cass;
/**
* Foreign sync
*/
arak: Arak;
}
export interface Vats {
[desk: string]: Vat;
}

View File

@ -15,4 +15,6 @@ export * as settings from './settings';
export * from './s3';
export * as s3 from './s3';
export * from './lib';
export * from './lib/BigIntOrderedMap';
export * from './lib/BigIntOrderedMap';
export * as hood from './hood';
export * from './hood';