@foss.global/interfaces 1.1.0 → 2.1.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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 2026-10-13 - 2.1.0
4
+
5
+ ### Features
6
+
7
+ - add origin and atomic push contracts for the Gitea import (data)
8
+ - `IOriginRef` and `TOriginState`: where a native entity came from (`native`, `imported` with the source forge instance and entity id, or `unknown`); an identity only, never a URL, path or authority.
9
+ - `IGitManagerAtomicPushRequest` with leased `IGitManagerAtomicPushRefUpdate`s and the all-or-nothing `IGitManagerAtomicPushResult` (`ok`, `stale` or `rejected` per ref); https or loopback-http remotes only.
10
+ - `IGitManagerSetDefaultBranchRequest` points a repository's HEAD at an existing branch.
11
+
12
+ ## 2026-10-13 - 2.0.0
13
+
14
+ ### Features
15
+
16
+ - add GitManager remote transfer options and the repository size contract (gitmanager)
17
+ - `IGitManagerRemoteTransferOptions` on `IGitManagerImportMirrorRequest` and the new `IGitManagerRefreshMirrorRequest`: an HTTP Basic `credential` carried outside the URL, command line and Git config, `caCertificates` for a private CA, and a `timeoutMs` up to six hours.
18
+ - `IGitManagerRepositorySize`: object count, uncompressed object bytes and object database storage bytes.
19
+
20
+ ### Breaking Changes
21
+
22
+ - measure Git objects and LFS presence in the forge source inventory (data)
23
+ - `IForgeSourceGitCounts` gains the required measures `objects` and `objectBytes`, and `IForgeSourceLfsCounts` gains `missingObjects`; producers must fill them. LFS `objects` and `bytes` now count only the referenced objects the forge holds.
24
+
25
+ ### Maintenance
26
+
27
+ - update release tooling: pnpm 12.10.1 (deps)
28
+
3
29
  ## 2026-10-13 - 1.1.0
4
30
 
5
31
  ### Features
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@foss.global/interfaces',
6
- version: '1.1.0',
6
+ version: '2.1.0',
7
7
  description: 'Shared TypeScript interfaces and TypedRequest contracts for the foss.global Git platform ecosystem.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx5QkFBeUI7SUFDL0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHFHQUFxRztDQUNuSCxDQUFBIn0=
@@ -118,6 +118,10 @@ export interface IForgeSourceOwnerTotals {
118
118
  sshKeys: TForgeSourceMeasure;
119
119
  gpgKeys: TForgeSourceMeasure;
120
120
  }
121
+ /**
122
+ * Ref and object counts read at the Git level, from a mirror clone of every
123
+ * ref the forge advertises, except `reportedSizeKiB`.
124
+ */
121
125
  export interface IForgeSourceGitCounts {
122
126
  /** As reported by the forge, in KiB; not a transfer size. */
123
127
  reportedSizeKiB: TForgeSourceMeasure;
@@ -126,10 +130,22 @@ export interface IForgeSourceGitCounts {
126
130
  /** Hidden refs that preserve pull request heads. */
127
131
  pullRequestRefs: TForgeSourceMeasure;
128
132
  otherRefs: TForgeSourceMeasure;
133
+ /** Distinct Git objects reachable from those refs. */
134
+ objects: TForgeSourceMeasure;
135
+ /** Sum of the uncompressed sizes of those objects; independent of how the forge packs them. */
136
+ objectBytes: TForgeSourceMeasure;
129
137
  }
138
+ /**
139
+ * LFS objects that pointers in any reachable revision reference, by distinct
140
+ * object ID, checked for presence through the forge's LFS batch API.
141
+ */
130
142
  export interface IForgeSourceLfsCounts {
143
+ /** Referenced objects the forge holds. */
131
144
  objects: TForgeSourceMeasure;
145
+ /** Sizes of the objects the forge holds. */
132
146
  bytes: TForgeSourceMeasure;
147
+ /** Referenced objects the forge does not hold; they cannot be migrated. */
148
+ missingObjects: TForgeSourceMeasure;
133
149
  }
134
150
  export interface IForgeSourceCollaborationCounts {
135
151
  issues: TForgeSourceMeasure;
@@ -14,9 +14,127 @@ export interface IGitManagerRepositoryInfo extends IGitManagerRepositorySelector
14
14
  export interface IGitManagerInitBareRepositoryRequest extends IGitManagerRepositorySelector {
15
15
  defaultBranch?: string;
16
16
  }
17
- export interface IGitManagerImportMirrorRequest extends IGitManagerRepositorySelector {
17
+ /**
18
+ * Points a repository's HEAD at an existing branch, which clones then check
19
+ * out by default.
20
+ */
21
+ export interface IGitManagerSetDefaultBranchRequest extends IGitManagerRepositorySelector {
22
+ /** Branch name without `refs/heads/`, as in `IGitManagerRepositoryInfo.defaultBranch`; the branch must exist. */
23
+ defaultBranch: string;
24
+ }
25
+ /**
26
+ * HTTP Basic credentials for a remote Git transfer, such as a forge user name
27
+ * with an access token as the password. Neither part may contain control
28
+ * characters, and the user name may not contain `:`.
29
+ */
30
+ export interface IGitManagerRemoteBasicCredential {
31
+ kind: 'basic';
32
+ username: string;
33
+ password: string;
34
+ }
35
+ export type TGitManagerRemoteCredential = IGitManagerRemoteBasicCredential;
36
+ /**
37
+ * Options for one transfer from a remote repository.
38
+ *
39
+ * A credential reaches Git only through the Git process environment, as an
40
+ * `Authorization` header. It never appears in the remote URL, on a command
41
+ * line, in the repository's Git config, or in an error. A credential requires
42
+ * an `https` remote URL without user information, and Git does not follow
43
+ * HTTP redirects while it carries one.
44
+ */
45
+ export interface IGitManagerRemoteTransferOptions {
46
+ credential?: TGitManagerRemoteCredential;
47
+ /**
48
+ * PEM certificates that Git uses as its CA bundle for this transfer, in
49
+ * place of the default bundle file, for a remote behind a private CA.
50
+ */
51
+ caCertificates?: string[];
52
+ /** Wall-clock limit for the transfer in milliseconds; defaults to 120000, at most 21600000 (six hours). */
53
+ timeoutMs?: number;
54
+ }
55
+ /**
56
+ * Clones every ref of a remote into a new mirror repository. The stored
57
+ * `remote.origin.url` is `remoteUrl`, so it must never carry credentials;
58
+ * pass them as `credential`.
59
+ */
60
+ export interface IGitManagerImportMirrorRequest extends IGitManagerRepositorySelector, IGitManagerRemoteTransferOptions {
18
61
  remoteUrl: string;
19
62
  }
63
+ /** Fetches every ref of an imported mirror's remote again, pruning refs the remote no longer has. */
64
+ export interface IGitManagerRefreshMirrorRequest extends IGitManagerRepositorySelector, IGitManagerRemoteTransferOptions {
65
+ }
66
+ /**
67
+ * One ref change of an atomic push, guarded by a lease: the remote applies it
68
+ * only while its ref still points at `expectedOldObjectId`. Both object IDs
69
+ * are full hexadecimal object IDs; at least one of them is non-null.
70
+ */
71
+ export interface IGitManagerAtomicPushRefUpdate {
72
+ /** Full ref name on the remote, for example `refs/heads/main`. */
73
+ ref: string;
74
+ /** Object the remote ref must point at now; null creates the ref, which must not exist. */
75
+ expectedOldObjectId: string | null;
76
+ /** Object to set the remote ref to, present in the managed repository; null deletes the ref. */
77
+ newObjectId: string | null;
78
+ }
79
+ /**
80
+ * Pushes ref updates from a managed repository to a remote as one atomic
81
+ * transaction: the remote applies every update or none. The remote must
82
+ * advertise the `atomic` receive-pack capability; without it the push fails
83
+ * before any ref is sent and never falls back to ref-by-ref updates.
84
+ *
85
+ * `remoteUrl` is used for this push only and is never stored in the
86
+ * repository. It must be `https`, or `http` to a loopback host
87
+ * (`127.0.0.0/8`, `::1` or `localhost`); `ssh`, `git`, `file` and scp-like
88
+ * URLs are refused. Transfer options behave as for `importMirror`, except
89
+ * that a push credential is also accepted for `http` to a loopback host, which
90
+ * never leaves the machine; the URL must not carry user information.
91
+ */
92
+ export interface IGitManagerAtomicPushRequest extends IGitManagerRepositorySelector, IGitManagerRemoteTransferOptions {
93
+ remoteUrl: string;
94
+ /** Updates of distinct refs; at least one. */
95
+ updates: IGitManagerAtomicPushRefUpdate[];
96
+ }
97
+ /**
98
+ * Outcome of one ref as the remote reported it. `stale` means the lease
99
+ * failed: the remote ref did not point at the expected object. `rejected`
100
+ * covers every other refusal, such as a hook or ref protection, and also the
101
+ * refs the remote refused only because another ref of the same atomic push
102
+ * failed.
103
+ */
104
+ export type TGitManagerAtomicPushRefStatus = 'ok' | 'rejected' | 'stale';
105
+ export interface IGitManagerAtomicPushRefResult {
106
+ ref: string;
107
+ status: TGitManagerAtomicPushRefStatus;
108
+ /** Reason text the remote reported for the ref, when it gave one; credentials are redacted. */
109
+ message?: string;
110
+ }
111
+ /**
112
+ * Result of an atomic push. `applied` means every ref is `ok`; `rejected`
113
+ * means no ref changed on the remote, and `refs` says why.
114
+ */
115
+ export interface IGitManagerAtomicPushResult extends IGitManagerRepositorySelector {
116
+ status: 'applied' | 'rejected';
117
+ /** One result per requested update, in request order. */
118
+ refs: IGitManagerAtomicPushRefResult[];
119
+ }
120
+ /**
121
+ * The object database of one repository when it was measured. Objects of
122
+ * alternate object stores are not counted.
123
+ */
124
+ export interface IGitManagerRepositorySize extends IGitManagerRepositorySelector {
125
+ /** Distinct commits, trees, blobs and annotated tags, reachable or not. */
126
+ objectCount: number;
127
+ /**
128
+ * Sum of the uncompressed sizes of those objects. It does not depend on
129
+ * how the objects are packed, so equal object sets give equal values.
130
+ */
131
+ objectBytes: number;
132
+ /**
133
+ * Bytes of every file in the object database: loose objects, packs, their
134
+ * indexes and other pack metadata. It depends on packing.
135
+ */
136
+ storageBytes: number;
137
+ }
20
138
  /**
21
139
  * One page request of a repository's complete ref inventory.
22
140
  *
@@ -2,5 +2,6 @@ export * from './codefeed.js';
2
2
  export * from './forgeinventory.js';
3
3
  export * from './forgesourceinventory.js';
4
4
  export * from './gitmanager.js';
5
+ export * from './origin.js';
5
6
  export * from './public.js';
6
7
  export * from './runner.js';
@@ -2,6 +2,7 @@ export * from './codefeed.js';
2
2
  export * from './forgeinventory.js';
3
3
  export * from './forgesourceinventory.js';
4
4
  export * from './gitmanager.js';
5
+ export * from './origin.js';
5
6
  export * from './public.js';
6
7
  export * from './runner.js';
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9kYXRhL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYywyQkFBMkIsQ0FBQztBQUMxQyxjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsYUFBYSxDQUFDIn0=
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9kYXRhL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYywyQkFBMkIsQ0FBQztBQUMxQyxjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsYUFBYSxDQUFDIn0=
@@ -0,0 +1,35 @@
1
+ /** Kinds of source entity an import records its origin for. */
2
+ export type TOriginEntityKind = 'repository';
3
+ /**
4
+ * Identity of the source entity a native entity was imported from.
5
+ *
6
+ * It names the source by stable identifiers only. It carries no URLs, paths,
7
+ * configuration or run IDs, digests, or authority: it neither locates the
8
+ * source nor grants access to it.
9
+ */
10
+ export interface IOriginRef {
11
+ /** Operator-minted instanceId of the forge connection the entity was imported from. */
12
+ instanceId: string;
13
+ entityKind: TOriginEntityKind;
14
+ /** Source row ID as an opaque string; for a Gitea repository, its decimal repository ID. */
15
+ entityId: string;
16
+ /**
17
+ * Source ID of the parent when entity IDs are parent-scoped; otherwise null.
18
+ * Null for repositories, because Gitea repository IDs are unique within an
19
+ * instance. Later entity kinds define their parent.
20
+ */
21
+ parentId: string | null;
22
+ }
23
+ /**
24
+ * Where a native entity came from: created natively, imported from a
25
+ * recorded source, or not known, for example for an entity that predates
26
+ * origin tracking. `unknown` must never be read as `native`.
27
+ */
28
+ export type TOriginState = {
29
+ kind: 'native';
30
+ } | {
31
+ kind: 'imported';
32
+ origin: IOriginRef;
33
+ } | {
34
+ kind: 'unknown';
35
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JpZ2luLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvZGF0YS9vcmlnaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foss.global/interfaces",
3
- "version": "1.1.0",
3
+ "version": "2.1.0",
4
4
  "private": false,
5
5
  "description": "Shared TypeScript interfaces and TypedRequest contracts for the foss.global Git platform ecosystem.",
6
6
  "exports": {
package/readme.md CHANGED
@@ -153,6 +153,54 @@ instead of a page that would mix two states; the caller restarts without a
153
153
  cursor. A cursor is a transport continuation, not a durable replication
154
154
  checkpoint.
155
155
 
156
+ ### GitManager remote transfer and size contracts
157
+
158
+ `IGitManagerImportMirrorRequest` and `IGitManagerRefreshMirrorRequest` take
159
+ `IGitManagerRemoteTransferOptions`: an optional `credential`
160
+ (`TGitManagerRemoteCredential`, HTTP Basic), optional `caCertificates` (PEM,
161
+ used as Git's CA bundle for that transfer) and an optional `timeoutMs`
162
+ (default 120000, at most 21600000). A credential reaches Git only through the
163
+ Git process environment as an `Authorization` header, so it never appears in
164
+ the remote URL, on a command line, in the repository's Git config, or in an
165
+ error. It requires an `https` remote without user information, and Git does
166
+ not follow redirects while it carries one. A refresh reuses the mirror's stored
167
+ remote URL.
168
+
169
+ `IGitManagerRepositorySize` measures a repository's object database:
170
+ `objectCount` distinct objects, `objectBytes` (their uncompressed sizes, which
171
+ do not depend on packing) and `storageBytes` (every file of the object
172
+ database, which does).
173
+
174
+ ### GitManager atomic push and default branch contracts
175
+
176
+ `IGitManagerAtomicPushRequest` pushes `IGitManagerAtomicPushRefUpdate`s from a
177
+ managed repository to `remoteUrl` as one transaction: the remote applies every
178
+ update or none, and a remote that does not advertise the `atomic` capability is
179
+ refused rather than pushed to ref by ref. Every update is leased:
180
+ `expectedOldObjectId` is the object the remote ref must point at now (null to
181
+ create a ref that must not exist), and `newObjectId` is the object to set (null
182
+ to delete). The URL is used for that push only; it must be `https`, or `http` to
183
+ a loopback host. The transfer options are those of `importMirror`, except that
184
+ a push credential is also accepted for loopback `http`.
185
+
186
+ `IGitManagerAtomicPushResult` is `applied` when every ref is `ok` and
187
+ `rejected` when no ref changed. Each `IGitManagerAtomicPushRefResult` is `ok`,
188
+ `stale` (the lease failed) or `rejected` (a hook, ref protection, or another
189
+ ref of the same push failed), with the remote's reason as `message`.
190
+
191
+ `IGitManagerSetDefaultBranchRequest` points a repository's HEAD at an existing
192
+ branch, named as in `IGitManagerRepositoryInfo.defaultBranch`.
193
+
194
+ ### Origin contracts
195
+
196
+ `TOriginState` records where a native entity came from: `native`, `imported`
197
+ with an `IOriginRef`, or `unknown`, which never means native. An `IOriginRef`
198
+ names the source by the operator-minted forge connection `instanceId`, the
199
+ `entityKind` (`repository`), the source `entityId` (a Gitea repository's
200
+ decimal ID) and `parentId` (null for repositories, whose Gitea IDs are unique
201
+ per instance). It carries no URLs, paths, configuration or run IDs, digests, or
202
+ authority.
203
+
156
204
  ### Forge inventory contracts
157
205
 
158
206
  `IForgeInventoryReport`, `IForgeInventoryPage<TItem>`, `IForgeInventoryNamespace`,
@@ -194,7 +242,7 @@ import fidelity, checksummed manifests, or durable recovery checkpoints.
194
242
  `IForgeSourceInventoryReport` is the authenticated, read-only measurement of a
195
243
  source forge before its one-time migration, read with a site administrator's
196
244
  token. It counts users, organizations, teams, memberships, keys, packages by
197
- type, and per repository the Git refs, LFS objects, issues, pull requests,
245
+ type, and per repository the Git refs and objects, LFS objects, issues, pull requests,
198
246
  comments, reviews, reactions, attachments, releases (drafts included) with
199
247
  asset bytes, wiki pages, access settings, webhooks, push mirrors, Actions
200
248
  settings, and the Actions runs and artifacts that are archived rather than
@@ -209,6 +257,13 @@ administrator read and that is reissued rather than migrated, such as Gitea's
209
257
  user-scoped Actions secrets; everything readable is a measure instead.
210
258
  Reasons are sanitized text, never raw response bodies or URLs.
211
259
 
260
+ Git counts other than the forge-reported size, and LFS counts, are read at the
261
+ Git level from a mirror clone of every advertised ref: refs by namespace,
262
+ distinct objects and their uncompressed bytes, and the LFS objects that
263
+ pointers in any reachable revision reference. LFS objects are checked through
264
+ the forge's LFS batch API and split into held objects with their bytes and
265
+ `missingObjects`, which cannot be migrated.
266
+
212
267
  Owners are a `TForgeSourceOwnerInventory` union: an organization carries its
213
268
  members, teams, team memberships and repository grants, labels and Actions
214
269
  secret count; a user carries its account flags and SSH and GPG key counts.
@@ -231,7 +286,7 @@ Actions secret or variable values, webhook secrets, or mirror remote URLs.
231
286
 
232
287
  ## Exports
233
288
 
234
- - `data`: public DTOs for users, organizations, repositories, contents, commits, diffs, releases, issues, activity, news, stats, codefeed commit results, GitManager repository/read API results, forge and forge source inventories, and runner/CI contracts.
289
+ - `data`: public DTOs for users, organizations, repositories, contents, commits, diffs, releases, issues, activity, news, stats, codefeed commit results, GitManager repository/read/push API results, origin references, forge and forge source inventories, and runner/CI contracts.
235
290
  - `requests`: TypedRequest contracts for `codefeed`, `publicOverview`, `publicOrg`, `publicRepo`, `publicFile`, and `publicCommits`.
236
291
  - Barrel exports: all public data and request interfaces are also exported from the package root.
237
292
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@foss.global/interfaces',
6
- version: '1.1.0',
6
+ version: '2.1.0',
7
7
  description: 'Shared TypeScript interfaces and TypedRequest contracts for the foss.global Git platform ecosystem.'
8
8
  }
@@ -126,6 +126,10 @@ export interface IForgeSourceOwnerTotals {
126
126
  gpgKeys: TForgeSourceMeasure;
127
127
  }
128
128
 
129
+ /**
130
+ * Ref and object counts read at the Git level, from a mirror clone of every
131
+ * ref the forge advertises, except `reportedSizeKiB`.
132
+ */
129
133
  export interface IForgeSourceGitCounts {
130
134
  /** As reported by the forge, in KiB; not a transfer size. */
131
135
  reportedSizeKiB: TForgeSourceMeasure;
@@ -134,11 +138,23 @@ export interface IForgeSourceGitCounts {
134
138
  /** Hidden refs that preserve pull request heads. */
135
139
  pullRequestRefs: TForgeSourceMeasure;
136
140
  otherRefs: TForgeSourceMeasure;
141
+ /** Distinct Git objects reachable from those refs. */
142
+ objects: TForgeSourceMeasure;
143
+ /** Sum of the uncompressed sizes of those objects; independent of how the forge packs them. */
144
+ objectBytes: TForgeSourceMeasure;
137
145
  }
138
146
 
147
+ /**
148
+ * LFS objects that pointers in any reachable revision reference, by distinct
149
+ * object ID, checked for presence through the forge's LFS batch API.
150
+ */
139
151
  export interface IForgeSourceLfsCounts {
152
+ /** Referenced objects the forge holds. */
140
153
  objects: TForgeSourceMeasure;
154
+ /** Sizes of the objects the forge holds. */
141
155
  bytes: TForgeSourceMeasure;
156
+ /** Referenced objects the forge does not hold; they cannot be migrated. */
157
+ missingObjects: TForgeSourceMeasure;
142
158
  }
143
159
 
144
160
  export interface IForgeSourceCollaborationCounts {
@@ -29,10 +29,138 @@ export interface IGitManagerInitBareRepositoryRequest extends IGitManagerReposit
29
29
  defaultBranch?: string;
30
30
  }
31
31
 
32
- export interface IGitManagerImportMirrorRequest extends IGitManagerRepositorySelector {
32
+ /**
33
+ * Points a repository's HEAD at an existing branch, which clones then check
34
+ * out by default.
35
+ */
36
+ export interface IGitManagerSetDefaultBranchRequest extends IGitManagerRepositorySelector {
37
+ /** Branch name without `refs/heads/`, as in `IGitManagerRepositoryInfo.defaultBranch`; the branch must exist. */
38
+ defaultBranch: string;
39
+ }
40
+
41
+ /**
42
+ * HTTP Basic credentials for a remote Git transfer, such as a forge user name
43
+ * with an access token as the password. Neither part may contain control
44
+ * characters, and the user name may not contain `:`.
45
+ */
46
+ export interface IGitManagerRemoteBasicCredential {
47
+ kind: 'basic';
48
+ username: string;
49
+ password: string;
50
+ }
51
+
52
+ export type TGitManagerRemoteCredential = IGitManagerRemoteBasicCredential;
53
+
54
+ /**
55
+ * Options for one transfer from a remote repository.
56
+ *
57
+ * A credential reaches Git only through the Git process environment, as an
58
+ * `Authorization` header. It never appears in the remote URL, on a command
59
+ * line, in the repository's Git config, or in an error. A credential requires
60
+ * an `https` remote URL without user information, and Git does not follow
61
+ * HTTP redirects while it carries one.
62
+ */
63
+ export interface IGitManagerRemoteTransferOptions {
64
+ credential?: TGitManagerRemoteCredential;
65
+ /**
66
+ * PEM certificates that Git uses as its CA bundle for this transfer, in
67
+ * place of the default bundle file, for a remote behind a private CA.
68
+ */
69
+ caCertificates?: string[];
70
+ /** Wall-clock limit for the transfer in milliseconds; defaults to 120000, at most 21600000 (six hours). */
71
+ timeoutMs?: number;
72
+ }
73
+
74
+ /**
75
+ * Clones every ref of a remote into a new mirror repository. The stored
76
+ * `remote.origin.url` is `remoteUrl`, so it must never carry credentials;
77
+ * pass them as `credential`.
78
+ */
79
+ export interface IGitManagerImportMirrorRequest extends IGitManagerRepositorySelector, IGitManagerRemoteTransferOptions {
33
80
  remoteUrl: string;
34
81
  }
35
82
 
83
+ /** Fetches every ref of an imported mirror's remote again, pruning refs the remote no longer has. */
84
+ export interface IGitManagerRefreshMirrorRequest extends IGitManagerRepositorySelector, IGitManagerRemoteTransferOptions {}
85
+
86
+ /**
87
+ * One ref change of an atomic push, guarded by a lease: the remote applies it
88
+ * only while its ref still points at `expectedOldObjectId`. Both object IDs
89
+ * are full hexadecimal object IDs; at least one of them is non-null.
90
+ */
91
+ export interface IGitManagerAtomicPushRefUpdate {
92
+ /** Full ref name on the remote, for example `refs/heads/main`. */
93
+ ref: string;
94
+ /** Object the remote ref must point at now; null creates the ref, which must not exist. */
95
+ expectedOldObjectId: string | null;
96
+ /** Object to set the remote ref to, present in the managed repository; null deletes the ref. */
97
+ newObjectId: string | null;
98
+ }
99
+
100
+ /**
101
+ * Pushes ref updates from a managed repository to a remote as one atomic
102
+ * transaction: the remote applies every update or none. The remote must
103
+ * advertise the `atomic` receive-pack capability; without it the push fails
104
+ * before any ref is sent and never falls back to ref-by-ref updates.
105
+ *
106
+ * `remoteUrl` is used for this push only and is never stored in the
107
+ * repository. It must be `https`, or `http` to a loopback host
108
+ * (`127.0.0.0/8`, `::1` or `localhost`); `ssh`, `git`, `file` and scp-like
109
+ * URLs are refused. Transfer options behave as for `importMirror`, except
110
+ * that a push credential is also accepted for `http` to a loopback host, which
111
+ * never leaves the machine; the URL must not carry user information.
112
+ */
113
+ export interface IGitManagerAtomicPushRequest extends IGitManagerRepositorySelector, IGitManagerRemoteTransferOptions {
114
+ remoteUrl: string;
115
+ /** Updates of distinct refs; at least one. */
116
+ updates: IGitManagerAtomicPushRefUpdate[];
117
+ }
118
+
119
+ /**
120
+ * Outcome of one ref as the remote reported it. `stale` means the lease
121
+ * failed: the remote ref did not point at the expected object. `rejected`
122
+ * covers every other refusal, such as a hook or ref protection, and also the
123
+ * refs the remote refused only because another ref of the same atomic push
124
+ * failed.
125
+ */
126
+ export type TGitManagerAtomicPushRefStatus = 'ok' | 'rejected' | 'stale';
127
+
128
+ export interface IGitManagerAtomicPushRefResult {
129
+ ref: string;
130
+ status: TGitManagerAtomicPushRefStatus;
131
+ /** Reason text the remote reported for the ref, when it gave one; credentials are redacted. */
132
+ message?: string;
133
+ }
134
+
135
+ /**
136
+ * Result of an atomic push. `applied` means every ref is `ok`; `rejected`
137
+ * means no ref changed on the remote, and `refs` says why.
138
+ */
139
+ export interface IGitManagerAtomicPushResult extends IGitManagerRepositorySelector {
140
+ status: 'applied' | 'rejected';
141
+ /** One result per requested update, in request order. */
142
+ refs: IGitManagerAtomicPushRefResult[];
143
+ }
144
+
145
+ /**
146
+ * The object database of one repository when it was measured. Objects of
147
+ * alternate object stores are not counted.
148
+ */
149
+ export interface IGitManagerRepositorySize extends IGitManagerRepositorySelector {
150
+ /** Distinct commits, trees, blobs and annotated tags, reachable or not. */
151
+ objectCount: number;
152
+ /**
153
+ * Sum of the uncompressed sizes of those objects. It does not depend on
154
+ * how the objects are packed, so equal object sets give equal values.
155
+ */
156
+ objectBytes: number;
157
+ /**
158
+ * Bytes of every file in the object database: loose objects, packs, their
159
+ * indexes and other pack metadata. It depends on packing.
160
+ */
161
+ storageBytes: number;
162
+ }
163
+
36
164
  /**
37
165
  * One page request of a repository's complete ref inventory.
38
166
  *
package/ts/data/index.ts CHANGED
@@ -2,5 +2,6 @@ export * from './codefeed.js';
2
2
  export * from './forgeinventory.js';
3
3
  export * from './forgesourceinventory.js';
4
4
  export * from './gitmanager.js';
5
+ export * from './origin.js';
5
6
  export * from './public.js';
6
7
  export * from './runner.js';
@@ -0,0 +1,33 @@
1
+ /** Kinds of source entity an import records its origin for. */
2
+ export type TOriginEntityKind = 'repository';
3
+
4
+ /**
5
+ * Identity of the source entity a native entity was imported from.
6
+ *
7
+ * It names the source by stable identifiers only. It carries no URLs, paths,
8
+ * configuration or run IDs, digests, or authority: it neither locates the
9
+ * source nor grants access to it.
10
+ */
11
+ export interface IOriginRef {
12
+ /** Operator-minted instanceId of the forge connection the entity was imported from. */
13
+ instanceId: string;
14
+ entityKind: TOriginEntityKind;
15
+ /** Source row ID as an opaque string; for a Gitea repository, its decimal repository ID. */
16
+ entityId: string;
17
+ /**
18
+ * Source ID of the parent when entity IDs are parent-scoped; otherwise null.
19
+ * Null for repositories, because Gitea repository IDs are unique within an
20
+ * instance. Later entity kinds define their parent.
21
+ */
22
+ parentId: string | null;
23
+ }
24
+
25
+ /**
26
+ * Where a native entity came from: created natively, imported from a
27
+ * recorded source, or not known, for example for an entity that predates
28
+ * origin tracking. `unknown` must never be read as `native`.
29
+ */
30
+ export type TOriginState =
31
+ | { kind: 'native' }
32
+ | { kind: 'imported'; origin: IOriginRef }
33
+ | { kind: 'unknown' };