Skip to content

Commit

Permalink
fix: correct issues in typescript definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
themightychris committed Nov 13, 2024
1 parent 76b8421 commit 9b37d28
Showing 1 changed file with 89 additions and 73 deletions.
162 changes: 89 additions & 73 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
declare module 'git-client' {
export class Git {
constructor(options: { gitDir: string; workTree?: string });
}
}

declare module 'dockerode' {
export class Docker {
constructor(options: { socketPath: string });
}
}

declare module 'hologit' {
import { Git as GitClient } from 'git-client';
import { Docker } from 'dockerode';
Expand Down Expand Up @@ -60,15 +72,15 @@ declare module 'hologit' {
}

export class Git {
static async get(): Promise<typeof GitClient>;
static get(): Promise<typeof GitClient>;
constructor(options: GitOptions);
gitDir: string;
workTree?: string;
}

export class BlobObject {
static async write(repo: Repo, content: string): Promise<BlobObject>;
static async writeFromFile(repo: Repo, filePath: string): Promise<BlobObject>;
static write(repo: Repo, content: string): Promise<BlobObject>;
static writeFromFile(repo: Repo, filePath: string): Promise<BlobObject>;

constructor(repo: Repo, options: GitObjectOptions);

Expand All @@ -78,12 +90,12 @@ declare module 'hologit' {
isBlob: boolean;
type: 'blob';

async read(): Promise<string>;
read(): Promise<string>;
}

export class TreeObject {
static getEmptyTreeHash(): string;
static async createFromRef(repo: Repo, ref: string): Promise<TreeObject>;
static createFromRef(repo: Repo, ref: string): Promise<TreeObject>;

constructor(repo: Repo, options?: { hash?: string; parent?: TreeObject | null });

Expand All @@ -95,19 +107,19 @@ declare module 'hologit' {
type: 'tree';
mode: '040000';

async getHash(): Promise<string>;
getHash(): Promise<string>;
getWrittenHash(): string | null;
markDirty(): void;
async getChild(childPath: string): Promise<TreeObject | BlobObject | CommitObject | null>;
async writeChild(childPath: string, content: string | BlobObject): Promise<BlobObject>;
async getChildren(): Promise<{ [key: string]: TreeObject | BlobObject | CommitObject }>;
async getBlobMap(): Promise<{ [key: string]: BlobObject }>;
async deleteChild(childPath: string): Promise<void>;
async getSubtree(subtreePath: string, create?: boolean): Promise<TreeObject | null>;
async getSubtreeStack(subtreePath: string, create?: boolean): Promise<TreeObject[] | null>;
async write(): Promise<string>;
async merge(input: TreeObject, options?: MergeOptions, basePath?: string, preloadChildren?: boolean): Promise<void>;
async clone(): Promise<TreeObject>;
getChild(childPath: string): Promise<TreeObject | BlobObject | CommitObject | null>;
writeChild(childPath: string, content: string | BlobObject): Promise<BlobObject>;
getChildren(): Promise<{ [key: string]: TreeObject | BlobObject | CommitObject }>;
getBlobMap(): Promise<{ [key: string]: BlobObject }>;
deleteChild(childPath: string): Promise<void>;
getSubtree(subtreePath: string, create?: boolean): Promise<TreeObject | null>;
getSubtreeStack(subtreePath: string, create?: boolean): Promise<TreeObject[] | null>;
write(): Promise<string>;
merge(input: TreeObject, options?: MergeOptions, basePath?: string, preloadChildren?: boolean): Promise<void>;
clone(): Promise<TreeObject>;
}

export class CommitObject {
Expand All @@ -128,10 +140,10 @@ declare module 'hologit' {

getWorkspace(): Workspace;
getRepo(): Repo;
async readConfig(): Promise<any>;
async writeConfig(config?: any): Promise<void>;
async getConfig(): Promise<any>;
async getCachedConfig(): Promise<any>;
readConfig(): Promise<any>;
writeConfig(config?: any): Promise<void>;
getConfig(): Promise<any>;
getCachedConfig(): Promise<any>;
}

export class Branch extends Configurable {
Expand All @@ -141,17 +153,17 @@ declare module 'hologit' {

getKind(): 'holobranch';
getConfigPath(): string;
async isDefined(): Promise<boolean>;
isDefined(): Promise<boolean>;
getMapping(key: string): Mapping;
async getMappings(): Promise<Map<string, Mapping>>;
async composite(options: {
getMappings(): Promise<Map<string, Mapping>>;
composite(options: {
outputTree?: TreeObject;
fetch?: boolean | string[];
cacheFrom?: string | null;
cacheTo?: string | null;
}): Promise<TreeObject>;
getLens(name: string): Lens;
async getLenses(): Promise<Map<string, Lens>>;
getLenses(): Promise<Map<string, Lens>>;
}

export class Source extends Configurable {
Expand All @@ -163,21 +175,21 @@ declare module 'hologit' {

getKind(): 'holosource';
getConfigPath(): string;
async getSpec(): Promise<{ hash: string; ref: string; data: any }>;
async getCachedSpec(): Promise<{ hash: string; ref: string; data: any }>;
async queryRef(): Promise<{ hash: string; ref: string } | null>;
async hashWorkTree(): Promise<string | null>;
async getOutputTree(options?: {
getSpec(): Promise<{ hash: string; ref: string; data: any }>;
getCachedSpec(): Promise<{ hash: string; ref: string; data: any }>;
queryRef(): Promise<{ hash: string; ref: string } | null>;
hashWorkTree(): Promise<string | null>;
getOutputTree(options?: {
working?: boolean | null;
fetch?: boolean | string[];
cacheFrom?: string | null;
cacheTo?: string | null;
}): Promise<string>;
async getHead(options?: { required?: boolean; working?: boolean | null }): Promise<string | null>;
async getCachedHead(): Promise<string | null>;
async getBranch(): Promise<string | null>;
async fetch(options?: { depth?: number; unshallow?: boolean | null }, ...refs: string[]): Promise<{ refs: string[] }>;
async checkout(options?: { submodule?: boolean }): Promise<{
getHead(options?: { required?: boolean; working?: boolean | null }): Promise<string | null>;
getCachedHead(): Promise<string | null>;
getBranch(): Promise<string | null>;
fetch(options?: { depth?: number; unshallow?: boolean | null }, ...refs: string[]): Promise<{ refs: string[] }>;
checkout(options?: { submodule?: boolean }): Promise<{
path: string;
head: string;
branch: string | null;
Expand All @@ -195,21 +207,21 @@ declare module 'hologit' {

getKind(): 'hololens';
getConfigPath(): string;
async buildInputTree(inputRoot?: TreeObject): Promise<TreeObject>;
async buildSpec(inputTree: TreeObject): Promise<{
buildInputTree(inputRoot?: TreeObject): Promise<TreeObject>;
buildSpec(inputTree: TreeObject): Promise<{
hash: string;
ref: string;
data: any;
}>;
async executeSpec(specHash: string, options: {
executeSpec(specHash: string, options: {
refresh?: boolean;
save?: boolean;
repo?: Repo | null;
cacheFrom?: string | null;
cacheTo?: string | null;
}): Promise<string>;

static async executeSpec(specHash: string, options: {
static executeSpec(specHash: string, options: {
refresh?: boolean;
save?: boolean;
repo?: Repo | null;
Expand All @@ -226,86 +238,86 @@ declare module 'hologit' {
getWorkspace(): Workspace;
getKind(): 'holospace';
getConfigPath(): string;
async writeWorkingChanges(): Promise<void>;
writeWorkingChanges(): Promise<void>;
getBranch(name: string): Branch;
async getBranches(): Promise<Map<string, Branch>>;
getBranches(): Promise<Map<string, Branch>>;
getSource(name: string): Source;
async getSources(): Promise<Map<string, Source>>;
async getLayers(): Promise<Map<string, Map<string, Mapping>>>;
getSources(): Promise<Map<string, Source>>;
getLayers(): Promise<Map<string, Map<string, Mapping>>>;
getLens(name: string): Lens;
async getLenses(): Promise<Map<string, Lens>>;
getLenses(): Promise<Map<string, Lens>>;
}

export class Repo {
static async getFromEnvironment(options?: { ref?: string; working?: boolean }): Promise<Repo>;
static getFromEnvironment(options?: { ref?: string; working?: boolean }): Promise<Repo>;

constructor(options: RepoOptions);

gitDir: string;
ref: string;
workTree: string | null;

async getWorkspace(): Promise<Workspace>;
async createWorkspaceFromRef(ref: string): Promise<Workspace>;
async createWorkspaceFromTreeHash(hash: string): Promise<Workspace>;
async getGit(): Promise<GitClient>;
async resolveRef(ref?: string | null): Promise<string | null>;
getWorkspace(): Promise<Workspace>;
createWorkspaceFromRef(ref: string): Promise<Workspace>;
createWorkspaceFromTreeHash(hash: string): Promise<Workspace>;
getGit(): Promise<GitClient>;
resolveRef(ref?: string | null): Promise<string | null>;
createBlob(options: GitObjectOptions): BlobObject;
async writeBlob(content: string): Promise<BlobObject>;
async writeBlobFromFile(filePath: string): Promise<BlobObject>;
writeBlob(content: string): Promise<BlobObject>;
writeBlobFromFile(filePath: string): Promise<BlobObject>;
createTree(options?: { hash?: string; parent?: TreeObject | null }): TreeObject;
async createTreeFromRef(ref: string): Promise<TreeObject>;
createTreeFromRef(ref: string): Promise<TreeObject>;
createCommit(options: GitObjectOptions): CommitObject;
async hasCommit(commit: string): Promise<boolean>;
async hashWorkTree(): Promise<string>;
async watch(options: { callback: (treeHash: string, commitHash?: string) => void }): Promise<{
hasCommit(commit: string): Promise<boolean>;
hashWorkTree(): Promise<string>;
watch(options: { callback: (treeHash: string, commitHash?: string) => void }): Promise<{
watching: Promise<void>;
cancel: () => void;
}>;
}

export class Projection {
static async projectBranch(branch: Branch, options?: ProjectionOptions): Promise<string>;
static projectBranch(branch: Branch, options?: ProjectionOptions): Promise<string>;

constructor(options: { branch: Branch });

branch: Branch;
workspace: Workspace;
output: Workspace;

async composite(options: {
composite(options: {
fetch?: boolean | string[];
cacheFrom?: string | null;
cacheTo?: string | null;
}): Promise<void>;
async lens(options: {
lens(options: {
cacheFrom?: string | null;
cacheTo?: string | null;
}): Promise<void>;
async commit(ref: string, options?: {
commit(ref: string, options?: {
parentCommit?: string | null;
commitMessage?: string | null;
}): Promise<string>;
}

export class Studio {
static async cleanup(): Promise<void>;
static async getHab(): Promise<any>;
static async getDocker(): Promise<Docker>;
static async isEnvironmentStudio(): Promise<boolean>;
static async get(gitDir: string): Promise<Studio>;
static cleanup(): Promise<void>;
static getHab(): Promise<any>;
static getDocker(): Promise<Docker>;
static isEnvironmentStudio(): Promise<boolean>;
static get(gitDir: string): Promise<Studio>;

constructor(options: { gitDir: string; container: any });

container: any;
gitDir: string;

isLocal(): boolean;
async habExec(...command: any[]): Promise<string>;
async habPkgExec(pkg: string, bin: string, ...args: any[]): Promise<string>;
async holoExec(...command: any[]): Promise<string>;
async holoLensExec(spec: string): Promise<string>;
async getPackage(query: string, options?: { install?: boolean }): Promise<string | null>;
habExec(...command: any[]): Promise<string>;
habPkgExec(pkg: string, bin: string, ...args: any[]): Promise<string>;
holoExec(...command: any[]): Promise<string>;
holoLensExec(spec: string): Promise<string>;
getPackage(query: string, options?: { install?: boolean }): Promise<string | null>;
}

export class Mapping extends Configurable {
Expand All @@ -319,13 +331,17 @@ declare module 'hologit' {
getConfigPath(): string;
}

export class SpecObject extends BlobObject {
static async write(repo: Repo, kind: string, data: any): Promise<{
export class SpecObject {
constructor(repo: Repo, options: GitObjectOptions);

repo: Repo;
hash: string;
isSpec: boolean;

static write(repo: Repo, kind: string, data: any): Promise<{
hash: string;
ref: string;
}>;
static buildRef(kind: string, hash: string): string;

isSpec: boolean;
}
}

0 comments on commit 9b37d28

Please sign in to comment.