@warmhub/sdk-ts 0.164.0 → 0.165.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/changelog.json +5 -0
- package/dist/chunk-BNZnO7qO.js +37 -0
- package/dist/chunk-BNZnO7qO.js.map +1 -0
- package/dist/chunk-Cba4gWoh.js +2 -0
- package/dist/chunk-Cba4gWoh.js.map +1 -0
- package/dist/index.d.ts +362 -2
- package/dist/index.js +1 -1
- package/dist/node.d.ts +116 -0
- package/dist/node.js +2 -0
- package/dist/node.js.map +1 -0
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/package.json +5 -1
- package/dist/chunk-syQKriG4.js +0 -37
- package/dist/chunk-syQKriG4.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),t=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function n(e,t){return(e>>>t|e<<32-t)>>>0}var r=class{#e=Uint32Array.from(t);#t=/* @__PURE__ */ new Uint32Array(64);#n=/* @__PURE__ */ new Uint8Array(64);#r=0;#i=0;#a=!1;update(e){if(this.#a)throw Error(`SHA-256 hasher is already finalized`);if(this.#i+=e.length,!Number.isSafeInteger(this.#i))throw RangeError(`SHA-256 input length must be a safe integer`);let t=0;if(this.#r>0){let n=Math.min(64-this.#r,e.length);if(this.#n.set(e.subarray(0,n),this.#r),this.#r+=n,t=n,this.#r<64)return;this.#o(this.#n,0),this.#r=0}for(;t+64<=e.length;)this.#o(e,t),t+=64;t<e.length&&(this.#n.set(e.subarray(t),0),this.#r=e.length-t)}digestHex(){if(this.#a)throw Error(`SHA-256 hasher is already finalized`);this.#a=!0;let e=new Uint8Array(this.#r<56?64:128);e.set(this.#n.subarray(0,this.#r),0),e[this.#r]=128;let t=new DataView(e.buffer);t.setUint32(e.length-8,Math.floor(this.#i/536870912)),t.setUint32(e.length-4,this.#i<<3>>>0);for(let t=0;t<e.length;t+=64)this.#o(e,t);return Array.from(this.#e,e=>e.toString(16).padStart(8,`0`)).join(``)}#o(t,r){let i=this.#t;for(let e=0;e<16;e+=1){let n=r+e*4;i[e]=(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0}for(let e=16;e<64;e+=1){let t=i[e-15],r=i[e-2],a=(n(t,7)^n(t,18)^t>>>3)>>>0,o=(n(r,17)^n(r,19)^r>>>10)>>>0;i[e]=i[e-16]+a+i[e-7]+o>>>0}let a=this.#e,o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],f=a[6],p=a[7];for(let t=0;t<64;t+=1){let r=(n(u,6)^n(u,11)^n(u,25))>>>0,a=(u&d^~u&f)>>>0,m=p+r+a+e[t]+i[t]>>>0,h=((n(o,2)^n(o,13)^n(o,22))>>>0)+((o&s^o&c^s&c)>>>0)>>>0;p=f,f=d,d=u,u=l+m>>>0,l=c,c=s,s=o,o=m+h>>>0}a[0]=o+a[0]>>>0,a[1]=s+a[1]>>>0,a[2]=c+a[2]>>>0,a[3]=l+a[3]>>>0,a[4]=u+a[4]>>>0,a[5]=d+a[5]>>>0,a[6]=f+a[6]>>>0,a[7]=p+a[7]>>>0}},i=class extends Error{code;status;hint;retryAfter;errorCode;backendCode;details;constructor(e,t,n,r,i,a,o){super(t),this.name=`WarmHubError`,this.code=e,this.status=n,this.hint=r,this.retryAfter=i,this.errorCode=a,this.backendCode=a,this.details=o}get kind(){return this.code}},a=class extends i{constructor(e,t,n){super(e,t,n,void 0,void 0,e)}};const o=/* @__PURE__ */ new Set([`localhost`,`127.0.0.1`,`[::1]`]);function s(e,t){let n,r;try{n=new URL(e),r=new URL(t)}catch{throw new a(`FILE_DOWNLOAD_ORIGIN`,`The download URL is not a valid URL.`)}if(n.origin!==r.origin)throw new a(`FILE_DOWNLOAD_ORIGIN`,`The download URL is not on this deployment's files service (${r.origin}).`);if(n.username!==``||n.password!==``)throw new a(`FILE_DOWNLOAD_ORIGIN`,`The download URL must not carry credentials.`);if(n.protocol!==`https:`&&!o.has(n.hostname))throw new a(`FILE_DOWNLOAD_ORIGIN`,`The download URL must use https.`)}function c(e,t){return e.fileId===t.fileId&&e.generation===t.generation&&e.size===t.size&&e.sha256===t.sha256}function l(e,t){return t?.aborted===!0||e instanceof Error&&e.name===`AbortError`}function u(e,t,n){let r=/^bytes (\d+)-(\d+)\/(\d+)$/.exec(e.headers.get(`content-range`)?.trim()??``);return r!==null&&Number(r[1])===t&&Number(r[2])===n-1&&Number(r[3])===n}var d=class{transport;options;facts;url;reminted=!1;cancelled=!1;failures=0;received=0;hash=new r;reader;retries;constructor(e,t,n){if(this.transport=e,this.options=n,s(t.url,e.filesOrigin),this.facts=t,this.url=t.url,this.retries=n.retries??2,!Number.isInteger(this.retries)||this.retries<0)throw new a(`FILE_DOWNLOAD_UNEXPECTED`,`retries must be a non-negative integer.`)}get result(){return this.facts}async remint(){let e=await this.transport.mint(this.facts.wref,this.options.includeRetracted?{includeRetracted:!0}:{});if(!c(this.facts,e))throw new a(`FILE_DOWNLOAD_CHANGED`,`${this.facts.wref} no longer names the file this download started; download it again.`);s(e.url,this.transport.filesOrigin),this.url=e.url}async backOff(e,t=`FILE_DOWNLOAD_UNAVAILABLE`){if(this.failures+=1,this.failures>this.retries)throw new a(t,`The files service could not finish the download: ${e}`);await this.transport.sleep(1e3*this.failures,this.options.signal)}assertLive(){if(this.cancelled)throw new DOMException(`The download was cancelled.`,`AbortError`)}async open(){for(;;){this.assertLive();let e;try{e=await this.transport.fetch(this.url,{method:`GET`,headers:this.received>0?{range:`bytes=${this.received}-`}:{},credentials:`omit`,redirect:`manual`,...this.options.signal?{signal:this.options.signal}:{}})}catch(e){if(l(e,this.options.signal))throw e;this.assertLive(),await this.backOff(e instanceof Error?e.message:String(e));continue}this.cancelled&&(await e.body?.cancel(),this.assertLive());let{status:t}=e;if(t===401&&!this.reminted){await e.body?.cancel(),this.reminted=!0,await this.remint();continue}if(t>=500||t===429){await e.body?.cancel(),await this.backOff(`HTTP ${t}`);continue}let n=this.received===0?200:206;if(t!==n||!e.body||n===206&&!u(e,this.received,this.facts.size))throw await e.body?.cancel(),new a(`FILE_DOWNLOAD_UNEXPECTED`,t===404?`The files service no longer stores this file.`:`The files service answered HTTP ${t} where ${n} was expected.`,t);this.reader=e.body.getReader();return}}integrity(e){return new a(`FILE_DOWNLOAD_INTEGRITY`,e)}async next(){for(;;){this.reader||await this.open();let e=this.reader,t;try{t=await e.read()}catch(e){if(l(e,this.options.signal))throw e;if(this.reader=void 0,this.received>0&&this.received===this.facts.size)t={done:!0,value:void 0};else{await this.backOff(e instanceof Error?e.message:String(e));continue}}if(!t.done){if(t.value.byteLength===0)continue;if(this.received+=t.value.byteLength,this.received>this.facts.size)throw await e.cancel(),this.integrity(`Received more than the file's ${this.facts.size} bytes.`);return this.hash.update(t.value),t.value}if(this.cancelled)return;if(this.received<this.facts.size){this.reader=void 0,await this.backOff(`the stream ended at ${this.received} of ${this.facts.size} bytes`,`FILE_DOWNLOAD_INTEGRITY`);continue}let n=this.hash.digestHex();if(n!==this.facts.sha256)throw this.integrity(`The downloaded bytes hash to ${n}, not ${this.facts.sha256}.`);return}}async cancel(e){this.cancelled=!0,await this.reader?.cancel(e)}};async function f(e,t,n={}){let r=new d(e,await e.mint(t,n.includeRetracted?{includeRetracted:!0}:{}),n);await r.open();let i=new ReadableStream({async pull(e){try{let t=await r.next();t?e.enqueue(t):e.close()}catch(t){e.error(t)}},async cancel(e){await r.cancel(e)}});return{facts:r.result,body:i}}export{r as i,f as n,i as r,a as t};
|
|
2
|
+
//# sourceMappingURL=chunk-Cba4gWoh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-Cba4gWoh.js","names":["ROUND_CONSTANTS","INITIAL_STATE","rotr","value","bits","Sha256","#finished","#byteLength","bytes","offset","#blockLength","take","#block","#compress","tail","view","#state","word","schedule","#schedule","index","at","previous","recent","s0","s1","state","a","b","d","e","f","g","h","choice","temp1","temp2","WarmHubError","message","code","status","hint","retryAfter","errorCode","details","FileDownloadError","LOOPBACK_HOSTS","assertDownloadOrigin","parsed","origin","url","filesOrigin","sameFile","isAbort","signal","error","resumesAt","match","response","size","Download","transport","options","first","again","reason","expected","reader","chunk","sha256","openFileDownload","download","wref","body","controller"],"sources":["../../rules/src/repository-export/sha256.ts","../src/warmhub-error.ts","../src/file-download.ts"],"mappings":"AAKA,MAAMA,EAAkB,YAAY,KAAK,CACvC,WAAY,WAAY,WAAY,WAAY,UAAY,WAC5D,WAAY,WAAY,WAAY,UAAY,UAAY,WAC5D,WAAY,WAAY,WAAY,WAAY,WAAY,WAC5D,UAAY,UAAY,UAAY,WAAY,WAAY,WAC5D,WAAY,WAAY,WAAY,WAAY,WAAY,WAC5D,UAAY,UAAY,UAAY,UAAY,WAAY,WAC5D,WAAY,WAAY,WAAY,WAAY,WAAY,WAC5D,WAAY,WAAY,WAAY,WAAY,WAAY,UAC5D,UAAY,UAAY,UAAY,UAAY,UAAY,WAC5D,WAAY,WAAY,WAAY,WAAY,WAAY,WAC5D,WAAY,WAAY,WAAY,UACtC,CAAC,EAEKC,EAAgB,YAAY,KAAK,CACrC,WAAY,WAAY,WAAY,WAAY,WAAY,WAC5D,UAAY,UACd,CAAC,EAID,SAASC,EAAK,EAAe,EAAsB,CACjD,OAASC,IAAUC,EAASD,GAAU,GAAKC,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AAO,EAAQ,CACnB,MAAMgB,EAAS,OAAON,CAAM,CAC9B,CACF,CAAC,EACD,MAAO,CAAE,MAAOM,EAAS,OAAQ,MAAK,CACxC,C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1640,6 +1640,7 @@ type Capabilities = {
|
|
|
1640
1640
|
writeContractVersion: number;
|
|
1641
1641
|
features: Record<string, boolean>;
|
|
1642
1642
|
honoredClientFlags: Array<string>;
|
|
1643
|
+
filesOrigin?: string;
|
|
1643
1644
|
};
|
|
1644
1645
|
type GrantCreateInput = {
|
|
1645
1646
|
orgName: string;
|
|
@@ -5339,6 +5340,21 @@ type CredentialScope = (typeof CREDENTIAL_SCOPES)[number];
|
|
|
5339
5340
|
* @see https://docs.warmhub.ai/sdk-reference/functions/isknowncredentialscope/
|
|
5340
5341
|
*/
|
|
5341
5342
|
export declare function isKnownCredentialScope(value: string): value is CredentialScope;
|
|
5343
|
+
declare const fileStateSchema: z.ZodObject<{
|
|
5344
|
+
fileId: z.ZodString;
|
|
5345
|
+
status: z.ZodEnum<{
|
|
5346
|
+
pending: "pending";
|
|
5347
|
+
failed: "failed";
|
|
5348
|
+
ready: "ready";
|
|
5349
|
+
}>;
|
|
5350
|
+
generation: z.ZodNumber;
|
|
5351
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
5352
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
5353
|
+
mediaType: z.ZodNullable<z.ZodString>;
|
|
5354
|
+
filename: z.ZodNullable<z.ZodString>;
|
|
5355
|
+
verifiedAt: z.ZodNullable<z.ZodNumber>;
|
|
5356
|
+
}, z.core.$strip>;
|
|
5357
|
+
type FileState = z.infer<typeof fileStateSchema>;
|
|
5342
5358
|
/**
|
|
5343
5359
|
* Global search result kinds recognized by this build.
|
|
5344
5360
|
* @see https://docs.warmhub.ai/sdk-reference/variables/global_search_result_item_kinds/
|
|
@@ -5708,6 +5724,251 @@ export declare class WarmHubError extends Error {
|
|
|
5708
5724
|
constructor(code: string, message: string, status?: number, hint?: string, retryAfter?: number, errorCode?: string, details?: WarmHubErrorDetails);
|
|
5709
5725
|
get kind(): ErrorKind;
|
|
5710
5726
|
}
|
|
5727
|
+
/**
|
|
5728
|
+
* `file.url`: a ready version's signed download URL and the file's facts.
|
|
5729
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileurlresult/
|
|
5730
|
+
*/
|
|
5731
|
+
type FileUrlResult = {
|
|
5732
|
+
/** A 15-minute read capability: anyone holding it can fetch the bytes. */
|
|
5733
|
+
url: string;
|
|
5734
|
+
expiresAt: string;
|
|
5735
|
+
fileId: string;
|
|
5736
|
+
generation: number;
|
|
5737
|
+
size: number;
|
|
5738
|
+
sha256: string;
|
|
5739
|
+
mediaType: string;
|
|
5740
|
+
filename: string;
|
|
5741
|
+
/** The resolved version, `name@vN` (canonical when in another graph). */
|
|
5742
|
+
wref: string;
|
|
5743
|
+
};
|
|
5744
|
+
/**
|
|
5745
|
+
* Options for `client.file.url`.
|
|
5746
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileurloptions/
|
|
5747
|
+
*/
|
|
5748
|
+
type FileUrlOptions = {
|
|
5749
|
+
/** Serve a retracted version, as `thing.get` would read it. */
|
|
5750
|
+
includeRetracted?: boolean;
|
|
5751
|
+
};
|
|
5752
|
+
/**
|
|
5753
|
+
* Options for one download.
|
|
5754
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filedownloadoptions/
|
|
5755
|
+
*/
|
|
5756
|
+
type FileDownloadOptions = FileUrlOptions & {
|
|
5757
|
+
/** Resumes after a network error or 5xx; 2 by default. */
|
|
5758
|
+
retries?: number;
|
|
5759
|
+
signal?: AbortSignal;
|
|
5760
|
+
};
|
|
5761
|
+
/**
|
|
5762
|
+
* `client.file.download`: the facts, and a stream that verifies them as it ends.
|
|
5763
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filedownloadresult/
|
|
5764
|
+
*/
|
|
5765
|
+
type FileDownloadResult = {
|
|
5766
|
+
facts: FileUrlResult;
|
|
5767
|
+
/** Errors with `FILE_DOWNLOAD_INTEGRITY` when the bytes do not match. */
|
|
5768
|
+
body: ReadableStream<Uint8Array>;
|
|
5769
|
+
};
|
|
5770
|
+
/**
|
|
5771
|
+
* Stable codes of the errors a download throws.
|
|
5772
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filedownloaderrorcode/
|
|
5773
|
+
*/
|
|
5774
|
+
type FileDownloadErrorCode = 'FILE_DOWNLOAD_INTEGRITY' | 'FILE_DOWNLOAD_CHANGED' | 'FILE_DOWNLOAD_ORIGIN' | 'FILE_DOWNLOAD_UNAVAILABLE' | 'FILE_DOWNLOAD_UNEXPECTED' | 'FILE_DOWNLOAD_EXISTS';
|
|
5775
|
+
/**
|
|
5776
|
+
* A download that could not finish, or whose bytes did not verify.
|
|
5777
|
+
* @see https://docs.warmhub.ai/sdk-reference/classes/filedownloaderror/
|
|
5778
|
+
*/
|
|
5779
|
+
export declare class FileDownloadError extends WarmHubError {
|
|
5780
|
+
constructor(code: FileDownloadErrorCode, message: string, status?: number);
|
|
5781
|
+
}
|
|
5782
|
+
/**
|
|
5783
|
+
* The facts the origin recorded for a ready file.
|
|
5784
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileuploadreadyfacts/
|
|
5785
|
+
*/
|
|
5786
|
+
type FileUploadReadyFacts = {
|
|
5787
|
+
size: number;
|
|
5788
|
+
sha256: string;
|
|
5789
|
+
mediaType: string;
|
|
5790
|
+
filename: string;
|
|
5791
|
+
};
|
|
5792
|
+
/**
|
|
5793
|
+
* What a caller can do next: `retry` re-issues the ticket and uploads again,
|
|
5794
|
+
* `other_account` means the ticket belongs to another principal, `quota`
|
|
5795
|
+
* means the graph has no room.
|
|
5796
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileuploadhint/
|
|
5797
|
+
*/
|
|
5798
|
+
type FileUploadHint = 'retry' | 'other_account' | 'quota';
|
|
5799
|
+
/**
|
|
5800
|
+
* Stable codes of the errors an upload throws.
|
|
5801
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileuploaderrorcode/
|
|
5802
|
+
*/
|
|
5803
|
+
type FileUploadErrorCode = 'FILE_TICKET_REFUSED' | 'FILE_UPLOAD_FORBIDDEN' | 'FILE_OVER_QUOTA' | 'FILE_TOO_LARGE' | 'FILE_UPLOAD_SESSION_LOST' | 'FILE_UPLOAD_BAD_PARTS' | 'FILE_UPLOAD_IN_PROGRESS' | 'FILE_UPLOAD_INVALID' | 'FILE_UPLOAD_UNAVAILABLE' | 'FILE_UPLOAD_UNEXPECTED' | 'FILE_UPLOAD_REDIRECT' | 'FILE_UPLOAD_ORIGIN' | 'FILE_UPLOAD_INPUT';
|
|
5804
|
+
/**
|
|
5805
|
+
* Upload inputs. Every input is sized, and all but a one-shot stream are
|
|
5806
|
+
* replayable: each attempt re-reads its byte range, so a retry sends exactly
|
|
5807
|
+
* the bytes and `Content-Length` the first attempt did.
|
|
5808
|
+
*/
|
|
5809
|
+
type ByteStream = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Iterable<Uint8Array>;
|
|
5810
|
+
/**
|
|
5811
|
+
* A sized source that can be re-read from any offset, such as a file on disk.
|
|
5812
|
+
* @see https://docs.warmhub.ai/sdk-reference/interfaces/replayablefilesource/
|
|
5813
|
+
*/
|
|
5814
|
+
interface ReplayableFileSource {
|
|
5815
|
+
/** Total bytes; the upload sends exactly this many. */
|
|
5816
|
+
readonly size: number;
|
|
5817
|
+
/** A fresh stream of the bytes from `offset` to the end. */
|
|
5818
|
+
open(offset: number): ByteStream | Promise<ByteStream>;
|
|
5819
|
+
/** The file name recorded with the upload. */
|
|
5820
|
+
readonly name?: string;
|
|
5821
|
+
/** The media type recorded with the upload. */
|
|
5822
|
+
readonly mediaType?: string;
|
|
5823
|
+
/** The lowercase hex SHA-256 of the whole source, when it can compute one. */
|
|
5824
|
+
sha256?(): Promise<string>;
|
|
5825
|
+
}
|
|
5826
|
+
/**
|
|
5827
|
+
* An input every attempt can re-read: a `Blob` (or `File`), bytes, or a
|
|
5828
|
+
* {@link ReplayableFileSource}. Calls that commit before they upload take
|
|
5829
|
+
* only these.
|
|
5830
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/replayablefileuploadinput/
|
|
5831
|
+
*/
|
|
5832
|
+
type ReplayableFileUploadInput = Blob | Uint8Array | ReplayableFileSource;
|
|
5833
|
+
/**
|
|
5834
|
+
* A stream that can be read once; accepted only with `retries: 0`.
|
|
5835
|
+
* @see https://docs.warmhub.ai/sdk-reference/interfaces/oneshotfilesource/
|
|
5836
|
+
*/
|
|
5837
|
+
interface OneShotFileSource {
|
|
5838
|
+
readonly stream: ReadableStream<Uint8Array>;
|
|
5839
|
+
readonly size: number;
|
|
5840
|
+
readonly name?: string;
|
|
5841
|
+
readonly mediaType?: string;
|
|
5842
|
+
}
|
|
5843
|
+
/**
|
|
5844
|
+
* What a file upload reads: a `Blob` (or `File`), bytes, a
|
|
5845
|
+
* {@link ReplayableFileSource}, or a {@link OneShotFileSource}. In Node,
|
|
5846
|
+
* `fileFromPath` from `@warmhub/sdk-ts/node` gives a replayable source for a
|
|
5847
|
+
* path.
|
|
5848
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileuploadinput/
|
|
5849
|
+
*/
|
|
5850
|
+
type FileUploadInput = ReplayableFileUploadInput | OneShotFileSource;
|
|
5851
|
+
/**
|
|
5852
|
+
* The committed version an upload belongs to, pinned as `name@vN`.
|
|
5853
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileuploadtarget/
|
|
5854
|
+
*/
|
|
5855
|
+
type FileUploadTarget = {
|
|
5856
|
+
orgName: string;
|
|
5857
|
+
graphName: string;
|
|
5858
|
+
wref: string;
|
|
5859
|
+
};
|
|
5860
|
+
/**
|
|
5861
|
+
* Options for one upload.
|
|
5862
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileuploadoptions/
|
|
5863
|
+
*/
|
|
5864
|
+
type FileUploadOptions = {
|
|
5865
|
+
/** Enables waiting on a `pending` answer by polling this version's file. */
|
|
5866
|
+
target?: FileUploadTarget;
|
|
5867
|
+
/** The generation the ticket was minted for; read from the ticket when omitted. */
|
|
5868
|
+
generation?: number;
|
|
5869
|
+
/** Extra attempts per request on 429, 503 and network errors. Default 2. */
|
|
5870
|
+
retries?: number;
|
|
5871
|
+
signal?: AbortSignal;
|
|
5872
|
+
};
|
|
5873
|
+
/**
|
|
5874
|
+
* How an upload ended.
|
|
5875
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileuploadresult/
|
|
5876
|
+
*/
|
|
5877
|
+
type FileUploadResult = {
|
|
5878
|
+
outcome: 'ready';
|
|
5879
|
+
fileId?: string;
|
|
5880
|
+
file: FileUploadReadyFacts;
|
|
5881
|
+
} | {
|
|
5882
|
+
outcome: 'pending';
|
|
5883
|
+
fileId?: string;
|
|
5884
|
+
} | {
|
|
5885
|
+
outcome: 'failed';
|
|
5886
|
+
fileId?: string;
|
|
5887
|
+
reason: string;
|
|
5888
|
+
hint?: FileUploadHint;
|
|
5889
|
+
} | {
|
|
5890
|
+
outcome: 'superseded';
|
|
5891
|
+
fileId?: string;
|
|
5892
|
+
};
|
|
5893
|
+
/**
|
|
5894
|
+
* A file's state, as `file.get` reads it.
|
|
5895
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filestatusresult/
|
|
5896
|
+
*/
|
|
5897
|
+
type FileStatusResult = FileState;
|
|
5898
|
+
/**
|
|
5899
|
+
* `file.getMany`: each readable file, plus what was missing or not a file.
|
|
5900
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filegetmanyresult/
|
|
5901
|
+
*/
|
|
5902
|
+
type FileGetManyResult = {
|
|
5903
|
+
requested: number;
|
|
5904
|
+
items: {
|
|
5905
|
+
wref: string;
|
|
5906
|
+
file: FileState;
|
|
5907
|
+
}[];
|
|
5908
|
+
missing: string[];
|
|
5909
|
+
notFiles: string[];
|
|
5910
|
+
};
|
|
5911
|
+
/**
|
|
5912
|
+
* A re-issued upload ticket for a file's next generation.
|
|
5913
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileticket/
|
|
5914
|
+
*/
|
|
5915
|
+
type FileTicket = {
|
|
5916
|
+
fileId: string;
|
|
5917
|
+
generation: number;
|
|
5918
|
+
url: string;
|
|
5919
|
+
maxBytes: number;
|
|
5920
|
+
expiresAt: string;
|
|
5921
|
+
};
|
|
5922
|
+
/**
|
|
5923
|
+
* `file.measure`: the file's state, and whether a measure was queued.
|
|
5924
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filemeasureresult/
|
|
5925
|
+
*/
|
|
5926
|
+
type FileMeasureResult = FileState & {
|
|
5927
|
+
measuring: boolean;
|
|
5928
|
+
};
|
|
5929
|
+
/**
|
|
5930
|
+
* The hints a File operation declares, taken from the local input.
|
|
5931
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filehints/
|
|
5932
|
+
*/
|
|
5933
|
+
type FileHints = {
|
|
5934
|
+
size?: number;
|
|
5935
|
+
sha256?: string;
|
|
5936
|
+
mediaType?: string;
|
|
5937
|
+
filename?: string;
|
|
5938
|
+
};
|
|
5939
|
+
/**
|
|
5940
|
+
* Input for `client.file.create` and `client.file.revise`.
|
|
5941
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filewriteinput/
|
|
5942
|
+
*/
|
|
5943
|
+
type FileWriteInput = {
|
|
5944
|
+
/** The Thing's full name. */
|
|
5945
|
+
name: string;
|
|
5946
|
+
/** Sized and replayable: the upload after the commit may retry. */
|
|
5947
|
+
file: ReplayableFileUploadInput;
|
|
5948
|
+
/** A Shape that composes File; `File` itself when omitted. */
|
|
5949
|
+
shape?: string;
|
|
5950
|
+
/** The Thing's data; `{}` on create, the current data on revise. */
|
|
5951
|
+
data?: unknown;
|
|
5952
|
+
message?: string;
|
|
5953
|
+
};
|
|
5954
|
+
/**
|
|
5955
|
+
* What `create`, `revise` and `retry` did.
|
|
5956
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filewriteresult/
|
|
5957
|
+
*/
|
|
5958
|
+
type FileWriteResult = FileUploadResult & {
|
|
5959
|
+
/** The version the file belongs to, `name@vN`. */
|
|
5960
|
+
wref: string;
|
|
5961
|
+
};
|
|
5962
|
+
/**
|
|
5963
|
+
* A revise that sent nothing: the local bytes match the current version's,
|
|
5964
|
+
* and the call set no `data` or `shape`.
|
|
5965
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileunchangedresult/
|
|
5966
|
+
*/
|
|
5967
|
+
type FileUnchangedResult = {
|
|
5968
|
+
outcome: 'unchanged';
|
|
5969
|
+
wref: string;
|
|
5970
|
+
fileId: string;
|
|
5971
|
+
};
|
|
5711
5972
|
/**
|
|
5712
5973
|
* One v2 write operation, as `commit.apply`, `commit.validate`,
|
|
5713
5974
|
* `commit.applyStreaming` and `stream.append` accept it. Build them with
|
|
@@ -5961,6 +6222,45 @@ type WarmHubDecorations = Record<string, string>;
|
|
|
5961
6222
|
* @see https://docs.warmhub.ai/sdk-reference/functions/getresponsedecorations/
|
|
5962
6223
|
*/
|
|
5963
6224
|
export declare function getResponseDecorations(result: unknown): WarmHubDecorations | undefined;
|
|
6225
|
+
/**
|
|
6226
|
+
* How one attached file ended.
|
|
6227
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileattachmentoutcome/
|
|
6228
|
+
*/
|
|
6229
|
+
type FileAttachmentOutcome = FileUploadResult['outcome'] |
|
|
6230
|
+
/** The op errored or made no change, so it has no ticket. */
|
|
6231
|
+
'skipped' |
|
|
6232
|
+
/** The op committed with no ticket: its file was already ready (a replay). */
|
|
6233
|
+
'already-ready' |
|
|
6234
|
+
/** The op was never acknowledged. */
|
|
6235
|
+
'not-attempted';
|
|
6236
|
+
/**
|
|
6237
|
+
* One attached file's result.
|
|
6238
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileattachmentresult/
|
|
6239
|
+
*/
|
|
6240
|
+
type FileAttachmentResult = {
|
|
6241
|
+
name: string;
|
|
6242
|
+
opIndex: number;
|
|
6243
|
+
outcome: FileAttachmentOutcome;
|
|
6244
|
+
/** The committed version, `name@vN`, when the op committed. */
|
|
6245
|
+
wref?: string;
|
|
6246
|
+
fileId?: string;
|
|
6247
|
+
file?: Extract<FileUploadResult, {
|
|
6248
|
+
outcome: 'ready';
|
|
6249
|
+
}>['file'];
|
|
6250
|
+
reason?: string;
|
|
6251
|
+
hint?: FileUploadHint;
|
|
6252
|
+
/** The upload's error, when it threw. */
|
|
6253
|
+
error?: {
|
|
6254
|
+
code: string;
|
|
6255
|
+
message: string;
|
|
6256
|
+
hint?: string;
|
|
6257
|
+
};
|
|
6258
|
+
};
|
|
6259
|
+
/**
|
|
6260
|
+
* Files to upload after `commit.apply`, keyed by the File op's name.
|
|
6261
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/commitfiles/
|
|
6262
|
+
*/
|
|
6263
|
+
type CommitFiles = Readonly<Record<string, ReplayableFileUploadInput>>;
|
|
5964
6264
|
/**
|
|
5965
6265
|
* Shape field definitions — the value side of a shape's data.fields
|
|
5966
6266
|
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/shapefields/
|
|
@@ -6125,6 +6425,11 @@ export declare class PartialStreamSubmissionError extends Error {
|
|
|
6125
6425
|
* @see https://docs.warmhub.ai/sdk-reference/classes/partialstreamsubmissionerror/#cause
|
|
6126
6426
|
*/
|
|
6127
6427
|
readonly cause: unknown;
|
|
6428
|
+
/**
|
|
6429
|
+
* Set by `commit.apply` with `files`: each attachment's upload, made from
|
|
6430
|
+
* the tickets of the chunks that committed.
|
|
6431
|
+
*/
|
|
6432
|
+
files?: FileAttachmentResult[];
|
|
6128
6433
|
constructor(input: {
|
|
6129
6434
|
cause: unknown;
|
|
6130
6435
|
completedReceipts: readonly OperationEventReceipt$1[];
|
|
@@ -6159,6 +6464,8 @@ export declare class AllStreamOperationsFailedError extends Error {
|
|
|
6159
6464
|
readonly operations: SubmittedStreamResult['operations'];
|
|
6160
6465
|
readonly statusCounts: NonNullable<SubmittedStreamResult['statusCounts']>;
|
|
6161
6466
|
readonly cause?: StreamFailureCause;
|
|
6467
|
+
/** Set by `commit.apply` with `files`: every attachment, skipped. */
|
|
6468
|
+
files?: FileAttachmentResult[];
|
|
6162
6469
|
constructor(result: SubmittedStreamResult);
|
|
6163
6470
|
}
|
|
6164
6471
|
type StreamAppendUpload = NonNullable<SubmittedStreamResult['uploads']>[number];
|
|
@@ -7012,6 +7319,21 @@ export declare const createOperationEventRequestId: typeof createOperationEventS
|
|
|
7012
7319
|
* @see https://docs.warmhub.ai/sdk-reference/variables/sdk_version/
|
|
7013
7320
|
*/
|
|
7014
7321
|
export declare const SDK_VERSION: string;
|
|
7322
|
+
/**
|
|
7323
|
+
* An upload that could not finish. `code` names the failure; `uploadHint`
|
|
7324
|
+
* names what to do next, for a surface that words its own advice.
|
|
7325
|
+
* @see https://docs.warmhub.ai/sdk-reference/classes/fileuploaderror/
|
|
7326
|
+
*/
|
|
7327
|
+
export declare class FileUploadError extends WarmHubError {
|
|
7328
|
+
readonly uploadHint?: FileUploadHint;
|
|
7329
|
+
/** Bytes the graph has room for, on `FILE_OVER_QUOTA`. */
|
|
7330
|
+
readonly available?: number;
|
|
7331
|
+
constructor(code: FileUploadErrorCode, message: string, extra?: {
|
|
7332
|
+
status?: number;
|
|
7333
|
+
hint?: FileUploadHint;
|
|
7334
|
+
available?: number;
|
|
7335
|
+
});
|
|
7336
|
+
}
|
|
7015
7337
|
/**
|
|
7016
7338
|
* Former name of `GraphInfo`, kept for external callers.
|
|
7017
7339
|
*
|
|
@@ -9125,6 +9447,18 @@ export type GraphAccessResult = AccessResolveResult$1['graphs'][number];
|
|
|
9125
9447
|
* @internal
|
|
9126
9448
|
*/
|
|
9127
9449
|
export type OrgAccessResult = AccessResolveResult$1['orgs'][number];
|
|
9450
|
+
/** @internal Options for `commit.apply`. */
|
|
9451
|
+
export type CommitApplyOptions = WithRetiredGraphKeys<{
|
|
9452
|
+
committer?: string;
|
|
9453
|
+
componentRef?: string;
|
|
9454
|
+
chunkSize?: number;
|
|
9455
|
+
skipExisting?: boolean;
|
|
9456
|
+
streamId?: string;
|
|
9457
|
+
submissionId?: string;
|
|
9458
|
+
returnGraphSeq?: boolean;
|
|
9459
|
+
retry?: RetryPolicyOptions | false;
|
|
9460
|
+
files?: CommitFiles;
|
|
9461
|
+
}>;
|
|
9128
9462
|
/**
|
|
9129
9463
|
* HTTP client for WarmHub repository, organization, and component APIs.
|
|
9130
9464
|
* @see https://docs.warmhub.ai/sdk-reference/classes/warmhubclient/
|
|
@@ -9147,6 +9481,7 @@ export declare class WarmHubClient {
|
|
|
9147
9481
|
protected readonly getToken?: () => Promise<string | undefined>;
|
|
9148
9482
|
private readonly trpc;
|
|
9149
9483
|
private compatibilityCheck?;
|
|
9484
|
+
private capabilitiesRead?;
|
|
9150
9485
|
private overrideNoticePrinted;
|
|
9151
9486
|
private readonly compatibilityNoticesPrinted;
|
|
9152
9487
|
/**
|
|
@@ -9160,6 +9495,9 @@ export declare class WarmHubClient {
|
|
|
9160
9495
|
* a version below the backend's floor, or a declared flag it did not honor.
|
|
9161
9496
|
*/
|
|
9162
9497
|
private noteCompatibilityHeaders;
|
|
9498
|
+
private cachedCapabilities;
|
|
9499
|
+
private fileClientDeps;
|
|
9500
|
+
private applyWithFiles;
|
|
9163
9501
|
private noteCompatibilityOverride;
|
|
9164
9502
|
private assertWriteCompatible;
|
|
9165
9503
|
/**
|
|
@@ -9449,6 +9787,7 @@ export declare class WarmHubClient {
|
|
|
9449
9787
|
* @param opts.submissionId Caller-selected UUID correlating all chunks.
|
|
9450
9788
|
* When omitted, the SDK mints one before the first network request.
|
|
9451
9789
|
* @param opts.retry Retry policy for transient first-chunk failures, or `false` to disable automatic retry.
|
|
9790
|
+
* @param opts.files Files to upload once the commit lands, keyed by the name of the one add or revise carrying `file` that each belongs to. Needs Files and an operation array; every key and input is checked before anything is written, and the result's `files` reports each upload.
|
|
9452
9791
|
*/
|
|
9453
9792
|
apply: (orgName: string, graphName: string, message: string | undefined, operations: OperationSource, opts?: WithRetiredGraphKeys<{
|
|
9454
9793
|
committer?: string;
|
|
@@ -9459,7 +9798,10 @@ export declare class WarmHubClient {
|
|
|
9459
9798
|
submissionId?: string;
|
|
9460
9799
|
returnGraphSeq?: boolean;
|
|
9461
9800
|
retry?: RetryPolicyOptions | false;
|
|
9462
|
-
|
|
9801
|
+
files?: CommitFiles;
|
|
9802
|
+
}>) => Promise<OperationSubmitResult & {
|
|
9803
|
+
files?: FileAttachmentResult[];
|
|
9804
|
+
}>;
|
|
9463
9805
|
/**
|
|
9464
9806
|
* Submit operations over one full-duplex NDJSON request and consume result
|
|
9465
9807
|
* rows as groups commit.
|
|
@@ -10383,6 +10725,24 @@ export declare class WarmHubClient {
|
|
|
10383
10725
|
reason?: string;
|
|
10384
10726
|
}) => Promise<GrantRevokeResult>;
|
|
10385
10727
|
};
|
|
10728
|
+
/**
|
|
10729
|
+
* Files: read a file's state, upload to a ticket, and commit File Things
|
|
10730
|
+
* with their bytes. Every method needs Files enabled for this client and
|
|
10731
|
+
* refuses with `FILES_NOT_ENABLED` otherwise.
|
|
10732
|
+
* @see https://docs.warmhub.ai/sdk-reference/classes/warmhubclient/#file
|
|
10733
|
+
*/
|
|
10734
|
+
readonly file: {
|
|
10735
|
+
url: (orgName: string, graphName: string, wref: string, options?: FileUrlOptions) => Promise<FileUrlResult>;
|
|
10736
|
+
download: (orgName: string, graphName: string, wref: string, options?: FileDownloadOptions) => Promise<FileDownloadResult>;
|
|
10737
|
+
get: (orgName: string, graphName: string, wref: string) => Promise<FileStatusResult>;
|
|
10738
|
+
getMany: (orgName: string, graphName: string, wrefs: string[]) => Promise<FileGetManyResult>;
|
|
10739
|
+
ticket: (orgName: string, graphName: string, wref: string) => Promise<FileTicket>;
|
|
10740
|
+
measure: (orgName: string, graphName: string, wref: string) => Promise<FileMeasureResult>;
|
|
10741
|
+
upload: (url: string, file: FileUploadInput, options?: FileUploadOptions) => Promise<FileUploadResult>;
|
|
10742
|
+
create: (orgName: string, graphName: string, input: FileWriteInput) => Promise<FileWriteResult>;
|
|
10743
|
+
revise: (orgName: string, graphName: string, input: FileWriteInput) => Promise<FileWriteResult | FileUnchangedResult>;
|
|
10744
|
+
retry: (orgName: string, graphName: string, wref: string, file: FileUploadInput, options?: Omit<FileUploadOptions, "target" | "generation">) => Promise<FileWriteResult>;
|
|
10745
|
+
};
|
|
10386
10746
|
/**
|
|
10387
10747
|
* Read surface for things, assertions, histories, references, search, and in-place thing renames.
|
|
10388
10748
|
* @see https://docs.warmhub.ai/sdk-reference/classes/warmhubclient/#thing
|
|
@@ -11168,4 +11528,4 @@ export declare class WarmHubClient {
|
|
|
11168
11528
|
private requestJson;
|
|
11169
11529
|
private watchRepoQuery;
|
|
11170
11530
|
}
|
|
11171
|
-
export type { AddInput, AddOperation, CheckpointContentType, CliCallSecrets, CliCallVerificationFailureReason, CommitValidateInput, CommitValidateOperation, CommitValidateOperations, CommitValidateOptions, CommitValidateResult, ComponentInstallResultState, ComponentSummaryState, CredentialScope, GlobalSearchResultItemKind, Grant, GrantCreateOptions, GrantListOptions, GrantListResult, GrantRecipientSelector, GrantRevokeResult, GraphCheckpointAccess, GraphCheckpointStatus, GraphExportDeltaFormats, GraphExportErrorReason, GraphExportExpectation, GraphExportOptions, GraphExportPreparation, GraphExportPrepareOptions, GraphExportRestoreOptions, GraphExportRowMap, GraphExportRows, GraphExportSegmentOptions, HomepageFeaturedItemKind, KeepShapesRevise, OldNameDetails, Operation, OperationBuilderClient, OperationBuilderOp, OperationBuilderOptions, OperationSource, OrgAuthScope, OrgMemberStatus, OrgRole, ReaffirmInput, ReaffirmOperation, RemoveOperation, RenameOperation, RepoAuthScope, RestoreInput, RestoreOperation, RetractInput, RetractOperation, RetryPolicyOptions, ReviseInput, ReviseOperation, RewriteOperation, ShapeFields, ShapeValidatorResult, ShapesChoice, StreamAppendInput, StreamContinuationState, StreamingSubmissionHandle, StreamingSubmissionOptions, StreamingSubmissionRetryIdentity, StreamingSubmissionRow, ThingShapesReader, UndeclaredFieldsWarning, ValidationDiagnostic, ValidationResult, VerifiedCliCall, WarmHubDecorations, WarmHubErrorDetails, WriteOperation };
|
|
11531
|
+
export type { AddInput, AddOperation, CheckpointContentType, CliCallSecrets, CliCallVerificationFailureReason, CommitFiles, CommitValidateInput, CommitValidateOperation, CommitValidateOperations, CommitValidateOptions, CommitValidateResult, ComponentInstallResultState, ComponentSummaryState, CredentialScope, FileAttachmentOutcome, FileAttachmentResult, FileDownloadErrorCode, FileDownloadOptions, FileDownloadResult, FileGetManyResult, FileHints, FileMeasureResult, FileStatusResult, FileTicket, FileUnchangedResult, FileUploadErrorCode, FileUploadHint, FileUploadInput, FileUploadOptions, FileUploadReadyFacts, FileUploadResult, FileUploadTarget, FileUrlOptions, FileUrlResult, FileWriteInput, FileWriteResult, GlobalSearchResultItemKind, Grant, GrantCreateOptions, GrantListOptions, GrantListResult, GrantRecipientSelector, GrantRevokeResult, GraphCheckpointAccess, GraphCheckpointStatus, GraphExportDeltaFormats, GraphExportErrorReason, GraphExportExpectation, GraphExportOptions, GraphExportPreparation, GraphExportPrepareOptions, GraphExportRestoreOptions, GraphExportRowMap, GraphExportRows, GraphExportSegmentOptions, HomepageFeaturedItemKind, KeepShapesRevise, OldNameDetails, OneShotFileSource, Operation, OperationBuilderClient, OperationBuilderOp, OperationBuilderOptions, OperationSource, OrgAuthScope, OrgMemberStatus, OrgRole, ReaffirmInput, ReaffirmOperation, RemoveOperation, RenameOperation, ReplayableFileSource, ReplayableFileUploadInput, RepoAuthScope, RestoreInput, RestoreOperation, RetractInput, RetractOperation, RetryPolicyOptions, ReviseInput, ReviseOperation, RewriteOperation, ShapeFields, ShapeValidatorResult, ShapesChoice, StreamAppendInput, StreamContinuationState, StreamingSubmissionHandle, StreamingSubmissionOptions, StreamingSubmissionRetryIdentity, StreamingSubmissionRow, ThingShapesReader, UndeclaredFieldsWarning, ValidationDiagnostic, ValidationResult, VerifiedCliCall, WarmHubDecorations, WarmHubErrorDetails, WriteOperation };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,B as n,C as r,Ct as i,D as a,Dt as o,E as s,Et as c,F as l,G as u,H as d,I as f,J as p,K as m,L as h,M as g,N as _,O as v,Ot as y,P as b,Q as x,R as S,S as C,St as w,T,Tt as E,U as D,V as O,W as k,X as A,Y as j,Z as M,_ as N,_t as P,a as F,at as I,b as L,bt as R,c as z,ct as B,d as V,dt as H,et as U,f as W,ft as G,g as K,gt as q,h as J,ht as Y,i as X,it as Z,j as Q,k as $,l as ee,lt as te,m as ne,mt as re,n as ie,nt as ae,o as oe,ot as se,p as ce,pt as le,q as ue,r as de,rt as fe,s as pe,st as me,t as he,tt as ge,u as _e,ut as ve,v as ye,vt as be,w as xe,wt as Se,x as Ce,xt as we,y as Te,yt as Ee,z as De}from"./chunk-
|
|
1
|
+
import{$ as e,A as t,B as n,C as r,Ct as i,D as a,Dt as o,E as s,Et as c,F as l,G as u,H as d,I as f,J as p,K as m,L as h,M as g,N as _,O as v,Ot as y,P as b,Q as x,R as S,S as C,St as w,T,Tt as E,U as D,V as O,W as k,X as A,Y as j,Z as M,_ as N,_t as P,a as F,at as I,b as L,bt as R,c as z,ct as B,d as V,dt as H,et as U,f as W,ft as G,g as K,gt as q,h as J,ht as Y,i as X,it as Z,j as Q,k as $,l as ee,lt as te,m as ne,mt as re,n as ie,nt as ae,o as oe,ot as se,p as ce,pt as le,q as ue,r as de,rt as fe,s as pe,st as me,t as he,tt as ge,u as _e,ut as ve,v as ye,vt as be,w as xe,wt as Se,x as Ce,xt as we,y as Te,yt as Ee,z as De}from"./chunk-BNZnO7qO.js";import{f as Oe,s as ke}from"./chunk-DvEqOqwB.js";import{r as Ae,t as je}from"./chunk-Cba4gWoh.js";export{l as AllStreamOperationsFailedError,ke as CHECKPOINT_CONTENT_TYPES,w as CLI_INSTALL_REPO_HEADER,i as CLI_SIGNATURE_HEADER,Se as CLI_TIMESTAMP_HEADER,be as COMPONENT_INSTALL_RESULT_STATES,re as COMPONENT_SUMMARY_STATES,c as CONTENT_FIELD_LIMIT_ERROR,G as CREDENTIAL_SCOPES,Te as CliCallVerificationError,he as DEFAULT_API_URL,f as DEFAULT_STREAM_CHUNK_SIZE,A as DEPENDENCY_FAILED,je as FileDownloadError,d as FileUploadError,ve as GLOBAL_SEARCH_RESULT_ITEM_KINDS,s as GraphExportError,a as GraphExportSession,B as HOMEPAGE_FEATURED_ITEM_KINDS,u as MAX_COMMIT_VALIDATION_ENCODED_BYTES,m as MAX_COMMIT_VALIDATION_OPERATIONS,o as MAX_CONTENT_FIELD_BYTES,h as MAX_STREAM_APPEND_OPERATION_COUNT,E as MAX_WREFS_PER_THING_VERSION,se as ORG_AUTH_SCOPES,fe as ORG_MEMBER_STATUSES,ge as ORG_ROLES,$ as OperationBuilder,S as PartialStreamSubmissionError,q as REPO_AUTH_SCOPES,ce as RepositoryExportError,ne as RepositoryExportSession,Ce as SDK_VERSION,R as SUBSCRIBABLE_EVENT_TYPES,O as StreamSubmissionAggregator,C as StreamingSubmissionOutcomeUnknownError,ie as WarmHubClient,Ae as WarmHubError,M as WriteOperationError,T as applyGraphExportDelta,J as applyRepositoryExportDelta,k as collectDurableTokens,ue as commitValidateRequestBodyBytes,de as connectionErrorMessage,y as contentFieldLimitError,g as countStreamAppendResultStatuses,p as createCommitValidateInput,v as createGraphExportSession,t as createKeepShapesResolver,De as createOperationEventRequestId,n as createOperationEventSubmissionId,K as createRepositoryExportSession,j as encodeCommitValidateRequestBody,D as getResponseDecorations,X as isAllStreamOperationsFailedError,F as isConnectionError,_ as isDefiniteStreamAppendRejection,Oe as isKnownCheckpointContentType,Ee as isKnownComponentInstallResultState,Y as isKnownComponentSummaryState,le as isKnownCredentialScope,H as isKnownGlobalSearchResultItemKind,te as isKnownHomepageFeaturedItemKind,me as isKnownOrgAuthScope,Z as isKnownOrgMemberStatus,ae as isKnownOrgRole,P as isKnownRepoAuthScope,we as isKnownSubscribableEventType,oe as isRetryable,x as isShapeReference,pe as isWarmHubError,z as normalizeWref,I as operationEventStreamRequestId,r as readGraphExportStream,N as readRepositoryExportStream,ee as resolveFunctionLogMode,xe as restoreGraphExportSession,ye as restoreRepositoryExportSession,_e as sanitizeErrorMessage,V as sdkVersionIsBelowMinimum,e as shapeName,b as streamAppendResultStatus,Q as submitOperationsViaStream,W as toWarmHubError,U as validateAgainstShape,L as verifyCliCall};
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-only helpers, kept off the browser-safe main entry: reading an upload
|
|
3
|
+
* from disk and writing a verified download to it.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Upload inputs. Every input is sized, and all but a one-shot stream are
|
|
9
|
+
* replayable: each attempt re-reads its byte range, so a retry sends exactly
|
|
10
|
+
* the bytes and `Content-Length` the first attempt did.
|
|
11
|
+
*/
|
|
12
|
+
type ByteStream = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Iterable<Uint8Array>;
|
|
13
|
+
/**
|
|
14
|
+
* A sized source that can be re-read from any offset, such as a file on disk.
|
|
15
|
+
* @see https://docs.warmhub.ai/sdk-reference/interfaces/replayablefilesource/
|
|
16
|
+
*/
|
|
17
|
+
interface ReplayableFileSource {
|
|
18
|
+
/** Total bytes; the upload sends exactly this many. */
|
|
19
|
+
readonly size: number;
|
|
20
|
+
/** A fresh stream of the bytes from `offset` to the end. */
|
|
21
|
+
open(offset: number): ByteStream | Promise<ByteStream>;
|
|
22
|
+
/** The file name recorded with the upload. */
|
|
23
|
+
readonly name?: string;
|
|
24
|
+
/** The media type recorded with the upload. */
|
|
25
|
+
readonly mediaType?: string;
|
|
26
|
+
/** The lowercase hex SHA-256 of the whole source, when it can compute one. */
|
|
27
|
+
sha256?(): Promise<string>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `file.url`: a ready version's signed download URL and the file's facts.
|
|
31
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileurlresult/
|
|
32
|
+
*/
|
|
33
|
+
type FileUrlResult = {
|
|
34
|
+
/** A 15-minute read capability: anyone holding it can fetch the bytes. */
|
|
35
|
+
url: string;
|
|
36
|
+
expiresAt: string;
|
|
37
|
+
fileId: string;
|
|
38
|
+
generation: number;
|
|
39
|
+
size: number;
|
|
40
|
+
sha256: string;
|
|
41
|
+
mediaType: string;
|
|
42
|
+
filename: string;
|
|
43
|
+
/** The resolved version, `name@vN` (canonical when in another graph). */
|
|
44
|
+
wref: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Options for `client.file.url`.
|
|
48
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/fileurloptions/
|
|
49
|
+
*/
|
|
50
|
+
type FileUrlOptions = {
|
|
51
|
+
/** Serve a retracted version, as `thing.get` would read it. */
|
|
52
|
+
includeRetracted?: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Options for one download.
|
|
56
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filedownloadoptions/
|
|
57
|
+
*/
|
|
58
|
+
type FileDownloadOptions = FileUrlOptions & {
|
|
59
|
+
/** Resumes after a network error or 5xx; 2 by default. */
|
|
60
|
+
retries?: number;
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Options for {@link fileFromPath}.
|
|
65
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filefrompathoptions/
|
|
66
|
+
*/
|
|
67
|
+
export type FileFromPathOptions = {
|
|
68
|
+
/** The file name recorded with the upload; the path's base name by default. */
|
|
69
|
+
name?: string;
|
|
70
|
+
/** The media type; guessed from a common extension, else left to the server. */
|
|
71
|
+
mediaType?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A replayable upload input for a file on disk. Checks the file is a
|
|
75
|
+
* readable regular file now, and reopens it at the right offset on every
|
|
76
|
+
* attempt, so a retry resends exactly the same bytes.
|
|
77
|
+
* @see https://docs.warmhub.ai/sdk-reference/functions/filefrompath/
|
|
78
|
+
*/
|
|
79
|
+
export declare function fileFromPath(path: string, options?: FileFromPathOptions): Promise<ReplayableFileSource>;
|
|
80
|
+
/**
|
|
81
|
+
* Options for {@link downloadToPath}.
|
|
82
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/downloadtopathoptions/
|
|
83
|
+
*/
|
|
84
|
+
export type DownloadToPathOptions = FileDownloadOptions & {
|
|
85
|
+
/** Replace an existing file at the path. */
|
|
86
|
+
overwrite?: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* What {@link downloadToPath} wrote: the file's facts and the path.
|
|
90
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/downloadtopathresult/
|
|
91
|
+
*/
|
|
92
|
+
export type DownloadToPathResult = FileUrlResult & {
|
|
93
|
+
path: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The part of `WarmHubClient` a download to disk needs.
|
|
97
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/filedownloadclient/
|
|
98
|
+
*/
|
|
99
|
+
export type FileDownloadClient = {
|
|
100
|
+
file: {
|
|
101
|
+
download(orgName: string, graphName: string, wref: string, options?: FileDownloadOptions): Promise<{
|
|
102
|
+
facts: FileUrlResult;
|
|
103
|
+
body: ReadableStream<Uint8Array>;
|
|
104
|
+
}>;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Download a ready version to `path`, verified. The bytes land in this run's
|
|
109
|
+
* own temp file, `<path>.<random>.part`, created exclusively so an existing
|
|
110
|
+
* file or symlink is never followed, and move into place only once size and
|
|
111
|
+
* SHA-256 match; a failure or cancel removes it. An existing `path` is
|
|
112
|
+
* refused unless `overwrite`.
|
|
113
|
+
* @see https://docs.warmhub.ai/sdk-reference/functions/downloadtopath/
|
|
114
|
+
*/
|
|
115
|
+
export declare function downloadToPath(client: FileDownloadClient, orgName: string, graphName: string, wref: string, path: string, options?: DownloadToPathOptions): Promise<DownloadToPathResult>;
|
|
116
|
+
export type { ReplayableFileSource };
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./chunk-Cba4gWoh.js";import{access as t,link as n,lstat as r,open as i,rename as a,rm as o,stat as s}from"node:fs/promises";import{basename as c,extname as l}from"node:path";import{createHash as u,randomBytes as d}from"node:crypto";import{pipeline as f}from"node:stream/promises";import{constants as p,createReadStream as m}from"node:fs";const h={".csv":`text/csv`,".gif":`image/gif`,".htm":`text/html`,".html":`text/html`,".jpeg":`image/jpeg`,".jpg":`image/jpeg`,".json":`application/json`,".md":`text/markdown`,".mp3":`audio/mpeg`,".mp4":`video/mp4`,".pdf":`application/pdf`,".png":`image/png`,".svg":`image/svg+xml`,".txt":`text/plain`,".webp":`image/webp`,".zip":`application/zip`};async function g(e,n={}){let r=await s(e);if(!r.isFile())throw Error(`${e} is not a regular file`);await t(e,p.R_OK);let i=n.mediaType??h[l(e).toLowerCase()];return{size:r.size,name:n.name??c(e),...i?{mediaType:i}:{},open:t=>m(e,{start:t}),sha256:async()=>{let t=u(`sha256`);for await(let n of m(e))t.update(n);return t.digest(`hex`)}}}async function _(e){try{return await r(e),!0}catch(e){if(e.code===`ENOENT`)return!1;throw e}}function v(t){return new e(`FILE_DOWNLOAD_EXISTS`,`${t} already exists.`)}async function*y(e){let t=e.getReader(),n=!1;try{for(;;){let e=await t.read();if(e.done){n=!0;return}yield e.value}}finally{n||await t.cancel()}}async function b(e){await o(e,{force:!0})}async function x(e,t,n,r,a,o={}){let{overwrite:s=!1,...c}=o,l=`${a}.${d(4).toString(`hex`)}.part`;if(!s&&await _(a))throw v(a);let{facts:u,body:p}=await e.file.download(t,n,r,c),m;try{m=await i(l,`wx`)}catch(e){throw await p.cancel(),e}try{await f(y(p),m.createWriteStream()),await S(l,a,s)}catch(e){throw await b(l),e}return{...u,path:a}}async function S(e,t,r){if(r)await a(e,t);else{try{await n(e,t)}catch(e){throw e.code===`EEXIST`?v(t):e}await b(e)}}export{x as downloadToPath,g as fileFromPath};
|
|
2
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","names":["FileDownloadError","MEDIA_TYPES","fileFromPath","info","stat","path","access","constants","mediaType","options","extname","basename","createReadStream","offset","hash","createHash","chunk","exists","lstat","error","existsError","chunksOf","reader","body","done","removeEntry","rm","downloadToPath","downloadOptions","part","randomBytes","overwrite","client","orgName","graphName","wref","handle","open","pipeline","publish","facts","rename","link"],"sources":["../src/node.ts"],"mappings":"A,qWAqBA,MAAMC,EAAgD,CACpD,OAAQ,WACR,OAAQ,YACR,OAAQ,YACR,QAAS,YACT,QAAS,aACT,OAAQ,aACR,QAAS,mBACT,MAAO,gBACP,OAAQ,aACR,OAAQ,YACR,OAAQ,kBACR,OAAQ,YACR,OAAQ,gBACR,OAAQ,aACR,QAAS,aACT,OAAQ,iBACV,EAeA,eAAsBC,EACpB,EACA,EAA+B,CAAC,EACD,CAC/B,IAAMC,EAAO,MAAMC,EAAKC,CAAI,EAC5B,GAAI,CAACF,EAAK,OAAO,EAAG,MAAU,MAAM,GAAGE,EAAK,uBAAuB,EACnE,MAAMC,EAAOD,EAAME,EAAU,IAAI,EACjC,IAAMC,EACJC,EAAQ,WAAaR,EAAYS,EAAQL,CAAI,CAAC,CAAC,YAAY,GAC7D,MAAO,CACL,KAAMF,EAAK,KACX,KAAMM,EAAQ,MAAQE,EAASN,CAAI,EACnC,GAAIG,EAAY,CAAE,WAAU,EAAI,CAAC,EACjC,KAAO,GAAWI,EAAiBP,EAAM,CAAE,MAAOQ,CAAO,CAAC,EAC1D,OAAQ,SAAY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AAI,EAAGa,EAAO,kBAAkB,CAAC,EACzD,MAAMG,EAAQV,EAAMxB,EAAM0B,CAAS,CACrC,OAASZ,EAAO,CAEd,MADA,MAAMM,EAAYI,CAAI,EAChBV,CACR,CACA,MAAO,CAAE,GAAGqB,EAAO,MAAK,CAC1B,CAGA,eAAeD,EACb,EACA,EACA,EACe,CACf,GAAIR,EACF,MAAMU,EAAOZ,EAAMxB,CAAI,MAGzB,IAAI,CAEF,MAAMqC,EAAKb,EAAMxB,CAAI,CACvB,OAASc,EAAO,CAId,MAHKA,EAAgC,OAAS,SACtCC,EAAYf,CAAI,EAElBc,CACR,CACA,MAAMM,EAAYI,CAAI,CADtB,CAEF,C"}
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{f as e,n as t,t as n,x as r}from"./chunk-BNZnO7qO.js";import{r as i}from"./chunk-Cba4gWoh.js";import{createContext as a,useContext as o,useEffect as s,useMemo as c,useState as l}from"react";import{jsx as u}from"react/jsx-runtime";const d=a(null),f=a({isAuthenticated:!1,isLoading:!0});function p({apiUrl:e,children:n,auth:r,client:i,decorateResponses:a}){let o=i?.name,s=i?.version,l=r.getAccessToken,f=c(()=>new t({apiUrl:e,accessToken:async()=>await l()??void 0,client:{name:o,version:s},decorateResponses:a}),[e,o,s,a,l]);return/* @__PURE__ */ u(d.Provider,{value:f,children:/* @__PURE__ */ u(m,{auth:r,client:f,children:n})})}function m({auth:e,client:t,children:n}){let[r,i]=l(null),a=e.isAuthenticated&&r===t;s(()=>{if(!e.isAuthenticated){i(null);return}let n=!1;return t.auth.sync().then(()=>{n||i(t)}).catch(e=>{console.error(`auth.sync failed:`,e),n||i(t)}),()=>{n=!0}},[e.isAuthenticated,t]);let o=c(()=>({isAuthenticated:e.isAuthenticated&&a,isLoading:e.isLoading||e.isAuthenticated&&!a}),[e.isAuthenticated,e.isLoading,a]);return e.isLoading||e.isAuthenticated&&!a?null:/* @__PURE__ */ u(f.Provider,{value:o,children:n})}function h(){let e=o(d);if(!e)throw Error(`useWarmHubClient must be used within a WarmHubProvider`);return e}function g(){return o(f)}export{n as DEFAULT_API_URL,r as SDK_VERSION,t as WarmHubClient,i as WarmHubError,p as WarmHubProvider,e as toWarmHubError,g as useWarmHubAuth,h as useWarmHubClient};
|
|
2
2
|
//# sourceMappingURL=react.js.map
|