@foss.global/codefeed 5.1.0 → 5.3.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.
@@ -1,5 +1,9 @@
1
1
  import * as plugins from './plugins.js';
2
2
  import type { ILfsRequestOptions, TLfsDownload } from './classes.lfsbatchclient.js';
3
+ import type { TGiteaCanonicalPackageDocumentKind } from './giteasourcetransfer.documents.js';
4
+ type IPackageRecord = plugins.fossInterfaces.data.IForgeSourcePackageInventory;
5
+ type IPackageVersion = plugins.fossInterfaces.data.IForgeSourcePackageVersion;
6
+ type IPackageBlob = plugins.fossInterfaces.data.IForgeSourcePackageBlob;
3
7
  export interface IGiteaSourceTransferOptions {
4
8
  /** Instance root, including an optional deployment subpath. HTTPS is required. */
5
9
  baseUrl: string;
@@ -23,6 +27,8 @@ export interface IGiteaSourceTransferOptions {
23
27
  lfsTransferTimeoutMs?: number;
24
28
  /** Wall-clock limit of one release asset download, its closing identity reads included; defaults to 30 minutes, at most six hours. */
25
29
  releaseAssetTimeoutMs?: number;
30
+ /** Wall-clock limit of one package blob or file download, its closing identity read included; defaults to 30 minutes, at most six hours. */
31
+ packageTransferTimeoutMs?: number;
26
32
  }
27
33
  /**
28
34
  * A source repository: its owner's and its own name, which Git and LFS reach
@@ -64,18 +70,89 @@ export interface IGiteaReleaseAssetDownload {
64
70
  */
65
71
  stream: InstanceType<typeof plugins.stream.Readable>;
66
72
  }
73
+ /** A package as the source inventory recorded it: what a read names, and the owner id it checks Gitea still holds. */
74
+ export type TGiteaPackageSelector = Pick<IPackageRecord, 'owner' | 'ownerId' | 'type' | 'name'>;
75
+ /** A version as the source inventory recorded it; its id identifies it, so a tag pushed again is another version. */
76
+ export type TGiteaPackageVersionSelector = Pick<IPackageVersion, 'id' | 'version'>;
77
+ /** Content as the source inventory recorded it: the SHA-256 and size of a blob. */
78
+ export type TGiteaPackageContentSelector = Pick<IPackageBlob, 'sha256' | 'size'>;
79
+ /** A file of a version as the source inventory recorded it: its name and the content it holds. */
80
+ export interface IGiteaPackageFileSelector extends TGiteaPackageContentSelector {
81
+ name: string;
82
+ }
83
+ /**
84
+ * Metadata a package version carries beside its files: an npm version
85
+ * document, Swift release metadata, a Swift release's manifest
86
+ * (`Package.swift`, or an alternate `Package@swift-<v>.swift`), a crate
87
+ * version's line of the Cargo sparse index, or the description the Cargo
88
+ * search serves for a crate's latest version.
89
+ */
90
+ export type TGiteaPackageDocumentKind = TGiteaCanonicalPackageDocumentKind | 'swift-manifest';
91
+ export interface IGiteaPackageReadOptions {
92
+ /** Aborts the read with `request-aborted`, also while a stream is read. */
93
+ signal?: AbortSignal;
94
+ }
95
+ /** Reads an alternate Swift manifest. */
96
+ export interface IGiteaSwiftManifestReadOptions extends IGiteaPackageReadOptions {
97
+ /**
98
+ * The Swift version Gitea keys the alternate manifest by, trimmed as its
99
+ * `TrimmedVersionString` writes it (`5.8`, `5.9.1`; the patch only when it
100
+ * is not zero).
101
+ */
102
+ swiftVersion: string;
103
+ }
104
+ /** A container manifest with the exact bytes and `Content-Type` Gitea serves. */
105
+ export interface IGiteaContainerManifest {
106
+ /** `sha256:` and the hex digest the bytes were checked against. */
107
+ digest: string;
108
+ /** The `Content-Type` header verbatim: the media type the manifest was pushed with. */
109
+ mediaType: string;
110
+ bytes: Buffer;
111
+ }
112
+ /**
113
+ * A version's metadata document and its digest: a JSON document in its
114
+ * canonical form (`canonicalPackageDocument`), a Swift manifest verbatim.
115
+ */
116
+ export interface IGiteaPackageDocument {
117
+ kind: TGiteaPackageDocumentKind;
118
+ /** The id of the version the identity reads before and after the read confirmed. */
119
+ versionId: string;
120
+ /**
121
+ * The canonical JSON for every kind but `swift-manifest`, whose bytes are
122
+ * the stored manifest as Gitea serves it. The bytes Gitea served for a JSON
123
+ * document are not returned: their key order differs from read to read.
124
+ */
125
+ bytes: Buffer;
126
+ /** Lowercase hex SHA-256 of `bytes`. */
127
+ sha256: string;
128
+ /** The media type Gitea declared, without parameters. */
129
+ mediaType: string;
130
+ }
131
+ export interface IGiteaPackageDownload {
132
+ content: TGiteaPackageContentSelector;
133
+ /**
134
+ * The content's bytes, never held whole. The last chunk is held back until
135
+ * exactly `content.size` bytes have arrived, their SHA-256 equals
136
+ * `content.sha256` and, for a version's file, the closing identity read has
137
+ * passed. Destroying the stream ends the download.
138
+ */
139
+ stream: InstanceType<typeof plugins.stream.Readable>;
140
+ }
67
141
  export interface IGiteaMirrorImport {
68
142
  repository: plugins.TGitManagerRepositoryInfo;
69
143
  /** The repository size Gitea reported, in KiB, which sized the scratch reservation. */
70
144
  reportedSizeKiB: string;
71
145
  }
72
146
  /**
73
- * Reads a Gitea repository's Git data and LFS objects for its one-time
74
- * migration, with the reader's login and token: a mirror clone into a
75
- * GitManager the caller supplies, verified LFS object downloads and release
76
- * asset downloads. It never writes to Gitea: Git is read only through
77
- * `git-upload-pack`, LFS only through batch `download` requests and their
78
- * download actions, release assets only through GETs of their attachment.
147
+ * Reads a Gitea repository's Git data and LFS objects, and package content,
148
+ * for its one-time migration, with the reader's login and token: a mirror
149
+ * clone into a GitManager the caller supplies, verified LFS object downloads,
150
+ * release asset downloads, container manifests and blobs, package files and
151
+ * package metadata documents. It never writes to Gitea: Git is read only
152
+ * through `git-upload-pack`, LFS only through batch `download` requests and
153
+ * their download actions, release assets only through GETs of their
154
+ * attachment, packages only through GETs of the registries and the v1 package
155
+ * API.
79
156
  */
80
157
  export declare class GiteaSourceTransfer {
81
158
  #private;
@@ -150,4 +227,72 @@ export declare class GiteaSourceTransfer {
150
227
  * by the identity reads as for `downloadLfsObject`.
151
228
  */
152
229
  downloadReleaseAsset(repositoryArg: IGiteaSourceRepository, releaseIdArg: string, assetArg: TGiteaReleaseAssetSelector, optionsArg?: IGiteaReleaseAssetDownloadOptions): Promise<IGiteaReleaseAssetDownload>;
230
+ /**
231
+ * Reads one container manifest by digest from the registry with the
232
+ * reader's Basic credentials: its exact bytes, which must hash to `digest`
233
+ * (`package-manifest-digest-mismatch`), and its `Content-Type` verbatim,
234
+ * which must be an OCI or Docker image manifest, index or manifest list
235
+ * (`package-manifest-media-type-invalid`). A manifest is content-addressed,
236
+ * so no identity read is needed. Reading it counts a download of the version
237
+ * holding it, an accepted read stamp (S10 ruling, item 8).
238
+ */
239
+ readContainerManifest(packageArg: TGiteaPackageSelector, digestArg: string, optionsArg?: IGiteaPackageReadOptions): Promise<IGiteaContainerManifest>;
240
+ /**
241
+ * Downloads one container blob, a config or a layer, by digest from the
242
+ * registry with the reader's Basic credentials. The bytes stream verified:
243
+ * the last chunk is held back until exactly `content.size` bytes have
244
+ * arrived and their SHA-256 equals `content.sha256`. A blob is
245
+ * content-addressed, so no identity read is needed, and reading one counts
246
+ * no download. Rejects, or errors the stream, with a fixed code such as
247
+ * `http-<status>`, `package-content-size-mismatch` (a `content-length` that
248
+ * is not the size), `package-content-size-overrun`, `package-content-short-body`,
249
+ * `package-content-digest-mismatch` or `package-content-transfer-timed-out`.
250
+ */
251
+ downloadContainerBlob(packageArg: TGiteaPackageSelector, contentArg: TGiteaPackageContentSelector, optionsArg?: IGiteaPackageReadOptions): Promise<IGiteaPackageDownload>;
252
+ /**
253
+ * Downloads one file of a package version: a generic file, an npm tarball
254
+ * (`{package}/-/{version}/{file}`), a Swift source archive or a crate, by the
255
+ * route of the package's type with the reader's `token` authorization;
256
+ * container content is read with `readContainerManifest` and
257
+ * `downloadContainerBlob` (`package-type-unsupported`). The version is read
258
+ * by its id before the download and again after the last byte: it must
259
+ * still be the recorded version of the recorded owner, else
260
+ * `package-version-identity-changed`, or `http-404` once deleted. The bytes
261
+ * stream verified as for `downloadContainerBlob`. Reading a file counts a
262
+ * download of its version, an accepted read stamp (S10 ruling, item 8).
263
+ */
264
+ downloadPackageFile(packageArg: TGiteaPackageSelector, versionArg: TGiteaPackageVersionSelector, fileArg: IGiteaPackageFileSelector, optionsArg?: IGiteaPackageReadOptions): Promise<IGiteaPackageDownload>;
265
+ /**
266
+ * Reads one metadata document of a package version with the reader's
267
+ * `token` authorization, bracketed by identity reads of the version as for
268
+ * `downloadPackageFile`. None of these reads counts a download.
269
+ *
270
+ * - `npm-version`: the npm version document.
271
+ * - `swift-release`: Swift release metadata.
272
+ * - `swift-manifest`: the release's `Package.swift`, which must answer 200;
273
+ * with `swiftVersion`, the alternate manifest Gitea keys by that version,
274
+ * read without following a redirect. It resolves null only when Gitea
275
+ * answers 303 to the release's own `Package.swift` URL, its way of saying
276
+ * it holds no such manifest; a redirect anywhere else rejects with
277
+ * `swift-manifest-redirect-unexpected`, any other status with
278
+ * `http-<status>`.
279
+ * - `cargo-index-entry`: the version's line of the crate's sparse index;
280
+ * `package-document-missing` when the index has none.
281
+ * - `cargo-description`: `{"description":…}` of the crate's entry in the
282
+ * Cargo search (`q=<name>`, its exact name), which describes only the
283
+ * version with the highest id: its `max_version` must be this version,
284
+ * else `package-document-missing`, as when no entry has the name.
285
+ *
286
+ * A manifest comes back verbatim, every other document in its canonical
287
+ * form (`canonicalPackageDocument`, `document-not-canonical` when it has
288
+ * none), each with the SHA-256 of the returned bytes, which a consumer
289
+ * records beside the version id. A kind that does not belong to the
290
+ * package's type, or `swiftVersion` with another kind, rejects with
291
+ * `package-document-kind-invalid`, a `swiftVersion` Gitea would not key a
292
+ * manifest by with `swift-version-invalid`, both before any request; a
293
+ * document of another media type rejects with `invalid-content-type`.
294
+ */
295
+ readPackageDocument(packageArg: TGiteaPackageSelector, versionArg: TGiteaPackageVersionSelector, kindArg: 'swift-manifest', optionsArg: IGiteaSwiftManifestReadOptions): Promise<IGiteaPackageDocument | null>;
296
+ readPackageDocument(packageArg: TGiteaPackageSelector, versionArg: TGiteaPackageVersionSelector, kindArg: TGiteaPackageDocumentKind, optionsArg?: IGiteaPackageReadOptions): Promise<IGiteaPackageDocument>;
153
297
  }
298
+ export {};