Spaces:
Paused
Paused
File size: 3,414 Bytes
1070765 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | import type { CredentialsParams, RepoDesignation } from "../types/public";
export interface CommitDeletedEntry {
operation: "delete";
path: string;
}
export type ContentSource = Blob | URL;
export interface CommitFile {
operation: "addOrUpdate";
path: string;
content: ContentSource;
}
/**
* Opitmized when only the beginning or the end of the file is replaced
*
* todo: handle other cases
*/
export interface CommitEditFile {
operation: "edit";
path: string;
/** Later, will be ContentSource. For now simpler to just handle blobs */
originalContent: Blob;
edits: Array<{
/**
* Later, will be ContentSource. For now simpler to just handle blobs
*
* originalContent from [start, end) will be replaced by this
*/
content: Blob;
/**
* The start position of the edit in the original content
*/
start: number;
/**
* The end position of the edit in the original content
*
* originalContent from [start, end) will be replaced by the edit
*/
end: number;
}>;
}
export type CommitOperation = CommitDeletedEntry | CommitFile | CommitEditFile;
export type CommitParams = {
title: string;
description?: string;
repo: RepoDesignation;
operations: CommitOperation[];
/** @default "main" */
branch?: string;
/**
* Parent commit. Optional
*
* - When opening a PR: will use parentCommit as the parent commit
* - When committing on a branch: Will make sure that there were no intermediate commits
*/
parentCommit?: string;
isPullRequest?: boolean;
hubUrl?: string;
/**
* Whether to use web workers to compute SHA256 hashes.
*
* @default false
*/
useWebWorkers?: boolean | {
minSize?: number;
poolSize?: number;
};
/**
* Maximum depth of folders to upload. Files deeper than this will be ignored
*
* @default 5
*/
maxFolderDepth?: number;
/**
* Custom fetch function to use instead of the default one, for example to use a proxy or edit headers.
*/
fetch?: typeof fetch;
abortSignal?: AbortSignal;
/**
* @default true
*
* Use xet protocol: https://huggingface.co/blog/xet-on-the-hub to upload, rather than a basic S3 PUT
*/
useXet?: boolean;
} & Partial<CredentialsParams>;
export interface CommitOutput {
pullRequestUrl?: string;
commit: {
oid: string;
url: string;
};
hookOutput: string;
}
export type CommitProgressEvent = {
event: "phase";
phase: "preuploading" | "uploadingLargeFiles" | "committing";
} | {
event: "fileProgress";
path: string;
progress: number;
state: "hashing" | "uploading" | "error";
};
/**
* Internal function for now, used by commit.
*
* Can be exposed later to offer fine-tuned progress info
*
* CommitOutput is not present for bucket commits
*/
export declare function commitIter(params: CommitParams): AsyncGenerator<CommitProgressEvent, CommitOutput | undefined>;
export declare function commitIterBucket(params: CommitParams): AsyncGenerator<CommitProgressEvent>;
/**
* @returns undefined for bucket uploads, CommitOutput otherwise
*/
export declare function commit(params: CommitParams): Promise<CommitOutput | undefined>;
//# sourceMappingURL=commit.d.ts.map |