@foss.global/codefeed 5.5.0 → 5.7.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 +21 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.giteasourcefreeze.d.ts +99 -0
- package/dist_ts/classes.giteasourcefreeze.js +707 -0
- package/dist_ts/classes.giteasourceinventory.js +26 -4
- package/dist_ts/forgeinventory.transport.d.ts +7 -2
- package/dist_ts/forgeinventory.transport.js +33 -15
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- package/package.json +3 -3
- package/readme.md +68 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.giteasourcefreeze.ts +763 -0
- package/ts/classes.giteasourceinventory.ts +25 -3
- package/ts/forgeinventory.transport.ts +32 -14
- package/ts/index.ts +1 -0
|
@@ -25,6 +25,7 @@ type IInventory = plugins.fossInterfaces.data.IForgeSourceInventory;
|
|
|
25
25
|
type TAccessMode = plugins.fossInterfaces.data.TForgeSourceAccessMode;
|
|
26
26
|
type TTeamVisibility = plugins.fossInterfaces.data.TForgeSourceTeamVisibility;
|
|
27
27
|
type ITeamRecord = plugins.fossInterfaces.data.IForgeSourceTeamRecord;
|
|
28
|
+
type IOrganizationProfile = plugins.fossInterfaces.data.IForgeSourceOrganizationProfile;
|
|
28
29
|
type IUserSshKey = plugins.fossInterfaces.data.IForgeSourceUserSshKey;
|
|
29
30
|
type ICollaborator = plugins.fossInterfaces.data.IForgeSourceCollaborator;
|
|
30
31
|
type IDeployKey = plugins.fossInterfaces.data.IForgeSourceDeployKey;
|
|
@@ -917,6 +918,13 @@ export class GiteaSourceInventory {
|
|
|
917
918
|
const path = `/orgs/${encodeURIComponent(nameArg)}`;
|
|
918
919
|
const organization = validation.record((await this.#get(path, { signal: signalArg })).body);
|
|
919
920
|
if (segment(organization.name) !== nameArg) throw new validation.ForgeInventoryError('owner-identity-changed');
|
|
921
|
+
// Verbatim, '' when unset; the website is not validated, since a value Gitea's web form stored may not be a URL.
|
|
922
|
+
const profile: IOrganizationProfile = {
|
|
923
|
+
fullName: text(organization.full_name),
|
|
924
|
+
description: text(organization.description),
|
|
925
|
+
website: text(organization.website),
|
|
926
|
+
location: text(organization.location),
|
|
927
|
+
};
|
|
920
928
|
const labels = await this.#list(`${path}/labels`, { signal: signalArg });
|
|
921
929
|
const teams = await this.#list(`${path}/teams`, { signal: signalArg });
|
|
922
930
|
const memberships: TMeasure[] = [];
|
|
@@ -954,6 +962,7 @@ export class GiteaSourceInventory {
|
|
|
954
962
|
: null,
|
|
955
963
|
// Recorded by every owner unit; the composed inventory keeps them exactly when discovery selects collaboration.
|
|
956
964
|
labelRecords: labels.failure === null ? labels.items.map(labelRecord).sort(byId) : null,
|
|
965
|
+
profile,
|
|
957
966
|
};
|
|
958
967
|
}
|
|
959
968
|
|
|
@@ -970,6 +979,8 @@ export class GiteaSourceInventory {
|
|
|
970
979
|
restricted: requiredBoolean(user.restricted),
|
|
971
980
|
prohibitLogin: requiredBoolean(user.prohibit_login),
|
|
972
981
|
};
|
|
982
|
+
// Verbatim, '' when unset.
|
|
983
|
+
const fullName = text(user.full_name);
|
|
973
984
|
// As an administrator this lists every key of the user.
|
|
974
985
|
const sshKeys = await this.#list(`${path}/keys`, { signal: signalArg });
|
|
975
986
|
const keyRecords = sshKeys.items.map(userSshKey).sort((aArg, bArg) => compareDecimal(aArg.id, bArg.id));
|
|
@@ -983,7 +994,10 @@ export class GiteaSourceInventory {
|
|
|
983
994
|
sshKeys: listingMeasure(sshKeys),
|
|
984
995
|
gpgKeys: await this.#count(`${path}/gpg_keys`, { signal: signalArg }),
|
|
985
996
|
userRecord: sshKeys.failure === null
|
|
986
|
-
? {
|
|
997
|
+
? {
|
|
998
|
+
id: base.id, login: nameArg, active: flags.active, admin: flags.admin, restricted: flags.restricted, prohibitLogin: flags.prohibitLogin,
|
|
999
|
+
visibility: base.visibility, sshKeys: keyRecords, fullName,
|
|
1000
|
+
}
|
|
987
1001
|
: null,
|
|
988
1002
|
};
|
|
989
1003
|
}
|
|
@@ -1876,9 +1890,17 @@ export const composeGiteaSourceInventory = (
|
|
|
1876
1890
|
}
|
|
1877
1891
|
|
|
1878
1892
|
const collaborationSelected = discoveryArg.collaboration === true;
|
|
1879
|
-
/**
|
|
1893
|
+
/**
|
|
1894
|
+
* An organization keeps its label records exactly when discovery selects
|
|
1895
|
+
* collaboration. An organization profile or a user's full name a stored
|
|
1896
|
+
* result lacks (a reader before 5.7.0) stays absent and is a reason.
|
|
1897
|
+
*/
|
|
1880
1898
|
const ownerOfRun = (ownerArg: TOwner): TOwner => {
|
|
1881
|
-
if (ownerArg.kind
|
|
1899
|
+
if (ownerArg.kind === 'user') {
|
|
1900
|
+
if (ownerArg.userRecord && ownerArg.userRecord.fullName === undefined) addReason('user.userRecord.fullName: Measured by a generator that predates user full names.');
|
|
1901
|
+
return ownerArg;
|
|
1902
|
+
}
|
|
1903
|
+
if (ownerArg.profile === undefined) addReason('organization.profile: Measured by a generator that predates organization profiles.');
|
|
1882
1904
|
const { labelRecords, ...organization } = ownerArg;
|
|
1883
1905
|
if (!collaborationSelected) return organization;
|
|
1884
1906
|
if (labelRecords !== undefined) return { ...organization, labelRecords };
|
|
@@ -72,14 +72,32 @@ export interface INodeResponse extends IForgeTransportResponse {
|
|
|
72
72
|
sent: Promise<void>;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* A lookup that answers every name with `addressArg`, an IP address, in the
|
|
77
|
+
* form the caller asks for (one address, or a list with `all`).
|
|
78
|
+
*/
|
|
79
|
+
const fixedLookup = (addressArg: string): plugins.net.LookupFunction => {
|
|
80
|
+
const family = plugins.net.isIP(addressArg);
|
|
81
|
+
return (_hostnameArg, optionsArg, callbackArg) => {
|
|
82
|
+
if (optionsArg.all) callbackArg(null, [{ address: addressArg, family }]);
|
|
83
|
+
else callbackArg(null, addressArg, family);
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
75
87
|
/**
|
|
76
88
|
* Idle keep-alive agents that unreference their pooled sockets, so pooled
|
|
77
|
-
* connections never keep the process alive.
|
|
89
|
+
* connections never keep the process alive. With `connectAddressArg`, an IP
|
|
90
|
+
* address, every connection goes to that address on the URL's port instead
|
|
91
|
+
* of the one DNS gives for the URL's host; the Host header, the TLS server
|
|
92
|
+
* name and the certificate check stay the URL's host.
|
|
78
93
|
*/
|
|
79
|
-
export const createNodeAgents = (caCertificatesArg?: string[], allowHttpArg = false): INodeRequestAgents =>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
94
|
+
export const createNodeAgents = (caCertificatesArg?: string[], allowHttpArg = false, connectAddressArg?: string): INodeRequestAgents => {
|
|
95
|
+
const lookup = connectAddressArg === undefined ? {} : { lookup: fixedLookup(connectAddressArg) };
|
|
96
|
+
return {
|
|
97
|
+
https: new plugins.https.Agent({ ...(caCertificatesArg ? { ca: caCertificatesArg } : {}), ...lookup, keepAlive: true, timeout: idleSocketTimeoutMs }),
|
|
98
|
+
...(allowHttpArg ? { http: new plugins.http.Agent({ ...lookup, keepAlive: true, timeout: idleSocketTimeoutMs }) } : {}),
|
|
99
|
+
};
|
|
100
|
+
};
|
|
83
101
|
|
|
84
102
|
/** Waits until the request can take more body bytes; rejects once it has closed. */
|
|
85
103
|
const drained = (requestArg: InstanceType<typeof plugins.http.ClientRequest>): Promise<void> => new Promise((resolve, reject) => {
|
|
@@ -160,17 +178,17 @@ export const sendNodeRequest = (url: URL, requestArg: INodeRequest): Promise<INo
|
|
|
160
178
|
});
|
|
161
179
|
});
|
|
162
180
|
|
|
181
|
+
/** `sendNodeRequest` through `agentsArg` as a transport: a GET, or a POST of the body. */
|
|
182
|
+
export const createAgentTransport = (agentsArg: INodeRequestAgents): TForgeTransport => async (url, headers, signal, body, options) => {
|
|
183
|
+
const { sent: _sent, ...response } = await sendNodeRequest(url, {
|
|
184
|
+
method: body ? 'POST' : 'GET', headers, body, signal, agents: agentsArg, redirect: options?.redirect,
|
|
185
|
+
});
|
|
186
|
+
return response;
|
|
187
|
+
};
|
|
188
|
+
|
|
163
189
|
/**
|
|
164
190
|
* `node:https` with an owned keep-alive agent whose `ca` list replaces the
|
|
165
191
|
* default trust store for these connections only. The agent unreferences idle
|
|
166
192
|
* sockets, so pooled connections never keep the process alive.
|
|
167
193
|
*/
|
|
168
|
-
export const createHttpsTransport = (caCertificates: string[]): TForgeTransport =>
|
|
169
|
-
const agents = createNodeAgents(caCertificates);
|
|
170
|
-
return async (url, headers, signal, body, options) => {
|
|
171
|
-
const { sent: _sent, ...response } = await sendNodeRequest(url, {
|
|
172
|
-
method: body ? 'POST' : 'GET', headers, body, signal, agents, redirect: options?.redirect,
|
|
173
|
-
});
|
|
174
|
-
return response;
|
|
175
|
-
};
|
|
176
|
-
};
|
|
194
|
+
export const createHttpsTransport = (caCertificates: string[]): TForgeTransport => createAgentTransport(createNodeAgents(caCertificates));
|
package/ts/index.ts
CHANGED
|
@@ -487,6 +487,7 @@ export class CodeFeed {
|
|
|
487
487
|
}
|
|
488
488
|
export * from './classes.forgeinventory.js';
|
|
489
489
|
export * from './classes.forgeinventoryscanner.js';
|
|
490
|
+
export * from './classes.giteasourcefreeze.js';
|
|
490
491
|
export * from './classes.giteasourceinventory.js';
|
|
491
492
|
export * from './classes.giteasourcetransfer.js';
|
|
492
493
|
export * from './classes.lfsbatchclient.js';
|