@foss.global/codefeed 3.0.0 → 3.2.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.
@@ -0,0 +1,126 @@
1
+ import * as plugins from './plugins.js';
2
+ import type { IForgeRequestMetrics } from './forgeinventory.client.js';
3
+ /**
4
+ * The credential of an LFS endpoint. It is sent only as the `Authorization`
5
+ * header of batch requests to the configured endpoint, never to action hrefs
6
+ * and never in a URL, error or result.
7
+ */
8
+ export type TLfsBatchCredential =
9
+ /** HTTP Basic, such as a forge login with an access token as the password. */
10
+ {
11
+ kind: 'basic';
12
+ username: string;
13
+ password: string;
14
+ }
15
+ /** A complete `Authorization` header value, such as `Bearer <token>`. */
16
+ | {
17
+ kind: 'authorization';
18
+ value: string;
19
+ };
20
+ export interface ILfsBatchClientOptions {
21
+ /**
22
+ * The repository's LFS endpoint, normally `<repository>.git/info/lfs`:
23
+ * `https://`, or `http://` only to an IP literal in 127.0.0.0/8 or `[::1]`.
24
+ * No user information, query or fragment.
25
+ */
26
+ endpoint: string;
27
+ credential: TLfsBatchCredential;
28
+ /** PEM certificates that replace the default trust store for this client's HTTPS connections. */
29
+ caCertificates?: string[];
30
+ /** Deadline of a batch or verify request, and of the response headers and every idle gap of a transfer; defaults to 60 s, at most 300 s. */
31
+ requestTimeoutMs?: number;
32
+ /** Wall-clock limit of one object's upload or download; defaults to 30 minutes, at most six hours. */
33
+ transferTimeoutMs?: number;
34
+ /** Response-size budget of a batch answer; defaults to 4 MiB, at most 64 MiB. */
35
+ maxResponseBytes?: number;
36
+ /** Objects per batch request; defaults to 100, at most 100. */
37
+ batchSize?: number;
38
+ }
39
+ /** One LFS object: its SHA-256 as 64 lowercase hex digits and its size in bytes. */
40
+ export interface ILfsObjectId {
41
+ oid: string;
42
+ size: number;
43
+ }
44
+ export interface ILfsUploadObject extends ILfsObjectId {
45
+ /**
46
+ * Opens the object's bytes, called only when the server asks for them. The
47
+ * source must end when `signalArg` aborts; a Node.js `Readable` is also
48
+ * destroyed when the upload ends early.
49
+ */
50
+ open: (signalArg: AbortSignal) => AsyncIterable<Uint8Array> | Promise<AsyncIterable<Uint8Array>>;
51
+ }
52
+ export interface ILfsUploadResult extends ILfsObjectId {
53
+ /** `uploaded` when this call sent the object, `present` when the server already held it. */
54
+ outcome: 'uploaded' | 'present';
55
+ }
56
+ export interface ILfsPresence extends ILfsObjectId {
57
+ status: 'held' | 'missing';
58
+ }
59
+ /** A download: a stream of the verified object, or `missing` when the server answered error 404. */
60
+ export type TLfsDownload = (ILfsObjectId & {
61
+ status: 'available';
62
+ stream: InstanceType<typeof plugins.stream.Readable>;
63
+ }) | (ILfsObjectId & {
64
+ status: 'missing';
65
+ });
66
+ export interface ILfsRequestOptions {
67
+ signal?: AbortSignal;
68
+ }
69
+ /**
70
+ * The client's URL policy, for the endpoint and for every action href: an
71
+ * `https:` URL, or an `http:` URL whose host is an IP literal in 127.0.0.0/8
72
+ * or `[::1]`, without user information or fragment. Host names over HTTP,
73
+ * `localhost` included, are refused, because a name can resolve elsewhere.
74
+ */
75
+ export declare const isAllowedLfsUrl: (urlArg: URL) => boolean;
76
+ /**
77
+ * A provider-neutral Git LFS batch API client with the `basic` transfer
78
+ * adapter, bound to one LFS endpoint and its credential: uploads objects the
79
+ * server lacks, checks which objects it holds and downloads verified objects.
80
+ * Every request is bounded by deadlines, size budgets and an optional
81
+ * `AbortSignal`; redirects are never followed; errors are fixed
82
+ * `ForgeInventoryError` codes that carry no URL, header, credential or
83
+ * response text.
84
+ */
85
+ export declare class LfsBatchClient {
86
+ #private;
87
+ constructor(optionsArg: ILfsBatchClientOptions);
88
+ /** Batch requests sent and their response bytes; object transfers are not counted. */
89
+ get metrics(): IForgeRequestMetrics;
90
+ /**
91
+ * Uploads every object the server lacks: one batch `upload` request per
92
+ * `batchSize` objects, then for each object with an `upload` action a PUT of
93
+ * exactly `size` bytes, verified against `oid` while they stream, and the
94
+ * `verify` action when the server sent one. An object without an `upload`
95
+ * action is already present. Objects are sent one at a time after their
96
+ * batch answer; an object whose upload or verify action would expire within
97
+ * the expiry margin (30 s, or `requestTimeoutMs` when that is shorter) is
98
+ * asked for again alone, once, and fails with `lfs-action-expired` when the
99
+ * fresh answer is again too short-lived. Rejects on the first object that
100
+ * fails.
101
+ */
102
+ upload(objectsArg: ILfsUploadObject[], optionsArg?: ILfsRequestOptions): Promise<ILfsUploadResult[]>;
103
+ /**
104
+ * Asks the server through batch `download` requests which objects it holds,
105
+ * without downloading them: a download action means `held`, error 404
106
+ * `missing`. Any other object error rejects with `lfs-object-error-<code>`.
107
+ * The actions are not used, so their expiry is validated but not enforced.
108
+ */
109
+ checkPresence(objectsArg: ILfsObjectId[], optionsArg?: ILfsRequestOptions): Promise<ILfsPresence[]>;
110
+ /**
111
+ * Downloads one object: a batch `download` request, then a GET of the
112
+ * action's href with the action's headers; a download action that would
113
+ * expire within the expiry margin is asked for again once, as for `upload`.
114
+ * Resolves with `missing` when the
115
+ * server answered error 404, otherwise with a stream of the object that
116
+ * never holds it whole. The stream errors with `lfs-size-overrun`,
117
+ * `lfs-short-body` or `lfs-digest-mismatch` before its last chunk when the
118
+ * bytes are not the object, with `request-aborted` when `signal` aborts and
119
+ * with `lfs-transfer-timed-out` when the transfer exceeds
120
+ * `transferTimeoutMs` or stalls for `requestTimeoutMs`. Destroying the
121
+ * stream ends the download.
122
+ */
123
+ download(objectArg: ILfsObjectId, optionsArg?: ILfsRequestOptions): Promise<TLfsDownload>;
124
+ /** Destroys this client's pooled connections. Idle ones close on their own after a few seconds. */
125
+ close(): void;
126
+ }