@ankhorage/repository 0.6.16 → 0.8.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 +12 -0
- package/README.md +1 -1
- package/dist/github/index.d.ts +6 -0
- package/dist/github/index.d.ts.map +1 -1
- package/dist/github/index.js +3 -0
- package/dist/github/index.js.map +1 -1
- package/dist/github/index.test.d.ts +2 -0
- package/dist/github/index.test.d.ts.map +1 -0
- package/dist/github/index.test.js +6 -0
- package/dist/github/index.test.js.map +1 -0
- package/dist/providers/github/adapters/createGitHubHttpClient.d.ts +17 -0
- package/dist/providers/github/adapters/createGitHubHttpClient.d.ts.map +1 -0
- package/dist/providers/github/adapters/createGitHubHttpClient.js +209 -0
- package/dist/providers/github/adapters/createGitHubHttpClient.js.map +1 -0
- package/dist/providers/github/adapters/createGitHubHttpClient.test.d.ts +2 -0
- package/dist/providers/github/adapters/createGitHubHttpClient.test.d.ts.map +1 -0
- package/dist/providers/github/adapters/createGitHubHttpClient.test.js +195 -0
- package/dist/providers/github/adapters/createGitHubHttpClient.test.js.map +1 -0
- package/dist/providers/github/adapters/createGitHubHttpRepositoryDiscoveryGateway.d.ts +9 -0
- package/dist/providers/github/adapters/createGitHubHttpRepositoryDiscoveryGateway.d.ts.map +1 -0
- package/dist/providers/github/adapters/createGitHubHttpRepositoryDiscoveryGateway.js +91 -0
- package/dist/providers/github/adapters/createGitHubHttpRepositoryDiscoveryGateway.js.map +1 -0
- package/dist/providers/github/adapters/createGitHubHttpRepositoryReadGateway.d.ts +3 -1
- package/dist/providers/github/adapters/createGitHubHttpRepositoryReadGateway.d.ts.map +1 -1
- package/dist/providers/github/adapters/createGitHubHttpRepositoryReadGateway.js +41 -60
- package/dist/providers/github/adapters/createGitHubHttpRepositoryReadGateway.js.map +1 -1
- package/dist/providers/github/adapters/createGitHubHttpRepositoryReadGateway.test.js +168 -0
- package/dist/providers/github/adapters/createGitHubHttpRepositoryReadGateway.test.js.map +1 -1
- package/dist/providers/github/adapters/rateLimitResponseAsync.d.ts +9 -0
- package/dist/providers/github/adapters/rateLimitResponseAsync.d.ts.map +1 -0
- package/dist/providers/github/adapters/rateLimitResponseAsync.js +44 -0
- package/dist/providers/github/adapters/rateLimitResponseAsync.js.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryDiscoveryOptions.d.ts +10 -0
- package/dist/providers/github/definitions/GitHubRepositoryDiscoveryOptions.d.ts.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryDiscoveryOptions.js +2 -0
- package/dist/providers/github/definitions/GitHubRepositoryDiscoveryOptions.js.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryDiscoveryResult.d.ts +25 -0
- package/dist/providers/github/definitions/GitHubRepositoryDiscoveryResult.d.ts.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryDiscoveryResult.js +12 -0
- package/dist/providers/github/definitions/GitHubRepositoryDiscoveryResult.js.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryMaterializationOptions.d.ts +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryMaterializationOptions.d.ts.map +1 -1
- package/dist/providers/github/definitions/GitHubRepositoryRevisionResolutionOptions.d.ts +9 -0
- package/dist/providers/github/definitions/GitHubRepositoryRevisionResolutionOptions.d.ts.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryRevisionResolutionOptions.js +2 -0
- package/dist/providers/github/definitions/GitHubRepositoryRevisionResolutionOptions.js.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryRevisionResolutionResult.d.ts +15 -0
- package/dist/providers/github/definitions/GitHubRepositoryRevisionResolutionResult.d.ts.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryRevisionResolutionResult.js +2 -0
- package/dist/providers/github/definitions/GitHubRepositoryRevisionResolutionResult.js.map +1 -0
- package/dist/providers/github/ports/GitHubRepositoryDiscoveryGateway.d.ts +18 -0
- package/dist/providers/github/ports/GitHubRepositoryDiscoveryGateway.d.ts.map +1 -0
- package/dist/providers/github/ports/GitHubRepositoryDiscoveryGateway.js +2 -0
- package/dist/providers/github/ports/GitHubRepositoryDiscoveryGateway.js.map +1 -0
- package/dist/providers/github/ports/GitHubRepositoryReadGateway.d.ts +7 -4
- package/dist/providers/github/ports/GitHubRepositoryReadGateway.d.ts.map +1 -1
- package/dist/providers/github/services/discoverGitHubRepositoriesAsync.d.ts +5 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesAsync.d.ts.map +1 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesAsync.js +9 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesAsync.js.map +1 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesWithGatewayAsync.d.ts +6 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesWithGatewayAsync.d.ts.map +1 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesWithGatewayAsync.js +91 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesWithGatewayAsync.js.map +1 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesWithGatewayAsync.test.d.ts +2 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesWithGatewayAsync.test.d.ts.map +1 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesWithGatewayAsync.test.js +55 -0
- package/dist/providers/github/services/discoverGitHubRepositoriesWithGatewayAsync.test.js.map +1 -0
- package/dist/providers/github/services/materializeGitHubRepositoryWithGatewayAsync.d.ts.map +1 -1
- package/dist/providers/github/services/materializeGitHubRepositoryWithGatewayAsync.js +17 -110
- package/dist/providers/github/services/materializeGitHubRepositoryWithGatewayAsync.js.map +1 -1
- package/dist/providers/github/services/materializeGitHubRepositoryWithGatewayAsync.test.js +8 -1
- package/dist/providers/github/services/materializeGitHubRepositoryWithGatewayAsync.test.js.map +1 -1
- package/dist/providers/github/services/parseGitHubRepositoryUrl.d.ts +8 -0
- package/dist/providers/github/services/parseGitHubRepositoryUrl.d.ts.map +1 -0
- package/dist/providers/github/services/parseGitHubRepositoryUrl.js +80 -0
- package/dist/providers/github/services/parseGitHubRepositoryUrl.js.map +1 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionAsync.d.ts +5 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionAsync.d.ts.map +1 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionAsync.js +9 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionAsync.js.map +1 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.d.ts +6 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.d.ts.map +1 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.js +20 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.js.map +1 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.d.ts +2 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.d.ts.map +1 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.js +111 -0
- package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.js.map +1 -0
- package/dist/providers/github/services/resolveGitHubUrlRevisionAsync.d.ts +9 -0
- package/dist/providers/github/services/resolveGitHubUrlRevisionAsync.d.ts.map +1 -0
- package/dist/providers/github/services/resolveGitHubUrlRevisionAsync.js +22 -0
- package/dist/providers/github/services/resolveGitHubUrlRevisionAsync.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { access, readFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { expect, test } from 'bun:test';
|
|
4
|
+
import { GitHubRepositoryDiscoveryError } from '../definitions/GitHubRepositoryDiscoveryResult.js';
|
|
4
5
|
import { materializeGitHubRepositoryWithGatewayAsync } from './materializeGitHubRepositoryWithGatewayAsync.js';
|
|
5
6
|
test('materializes an exact explicit GitHub revision and cleans up the isolated root', async () => {
|
|
6
7
|
const requestedRefs = [];
|
|
@@ -128,13 +129,16 @@ function createGateway(options) {
|
|
|
128
129
|
}));
|
|
129
130
|
return {
|
|
130
131
|
inspectRepositoryAsync: (target) => Promise.resolve({
|
|
132
|
+
id: '1',
|
|
133
|
+
owner: target.owner,
|
|
134
|
+
name: target.name,
|
|
131
135
|
defaultBranch: options.defaultBranch ?? 'main',
|
|
132
136
|
url: target.url,
|
|
133
137
|
}),
|
|
134
138
|
resolveRevisionAsync: (_target, ref) => {
|
|
135
139
|
options.requestedRefs?.push(ref);
|
|
136
140
|
if (options.acceptedRefs !== undefined && !options.acceptedRefs.includes(ref)) {
|
|
137
|
-
return Promise.reject(
|
|
141
|
+
return Promise.reject(refNotFoundError());
|
|
138
142
|
}
|
|
139
143
|
return Promise.resolve({ commitSha: 'commit-sha', treeSha: 'tree-sha' });
|
|
140
144
|
},
|
|
@@ -152,6 +156,9 @@ function createGateway(options) {
|
|
|
152
156
|
},
|
|
153
157
|
};
|
|
154
158
|
}
|
|
159
|
+
function refNotFoundError() {
|
|
160
|
+
return new GitHubRepositoryDiscoveryError('api-failure', 'GitHub repository revision request failed with HTTP 404.');
|
|
161
|
+
}
|
|
155
162
|
async function expectFailureAsync(operation, message) {
|
|
156
163
|
try {
|
|
157
164
|
await operation();
|
package/dist/providers/github/services/materializeGitHubRepositoryWithGatewayAsync.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materializeGitHubRepositoryWithGatewayAsync.test.js","sourceRoot":"","sources":["../../../../src/providers/github/services/materializeGitHubRepositoryWithGatewayAsync.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"materializeGitHubRepositoryWithGatewayAsync.test.js","sourceRoot":"","sources":["../../../../src/providers/github/services/materializeGitHubRepositoryWithGatewayAsync.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAC;AAEnG,OAAO,EAAE,2CAA2C,EAAE,MAAM,kDAAkD,CAAC;AAE/G,IAAI,CAAC,gFAAgF,EAAE,KAAK,IAAI,EAAE;IAChG,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,MAAM,OAAO,GAAG,aAAa,CAAC;QAC5B,aAAa;QACb,KAAK,EAAE;YACL,cAAc,EAAE,mBAAmB;YACnC,cAAc,EAAE,6BAA6B;SAC9C;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,2CAA2C,CAC9D,EAAE,GAAG,EAAE,mCAAmC,EAAE,GAAG,EAAE,cAAc,EAAE,EACjE,OAAO,CACR,CAAC;IAEF,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;IAChD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;QAChC,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,mCAAmC;QACxC,aAAa,EAAE,MAAM;KACtB,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ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CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACpC,MAAM,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,IAAY;IAChD,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GitHubRepositoryReadTarget } from '../ports/GitHubRepositoryReadGateway.js';
|
|
2
|
+
export interface ParsedGitHubRepositoryUrl {
|
|
3
|
+
readonly target: GitHubRepositoryReadTarget;
|
|
4
|
+
readonly refCandidates: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
/** Parse a normal GitHub repository, tree, blob, or commit URL into repository and ref intent. */
|
|
7
|
+
export declare function parseGitHubRepositoryUrl(value: string): ParsedGitHubRepositoryUrl;
|
|
8
|
+
//# sourceMappingURL=parseGitHubRepositoryUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseGitHubRepositoryUrl.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/services/parseGitHubRepositoryUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAE1F,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAC5C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED,kGAAkG;AAClG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,yBAAyB,CA6BjF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** Parse a normal GitHub repository, tree, blob, or commit URL into repository and ref intent. */
|
|
2
|
+
export function parseGitHubRepositoryUrl(value) {
|
|
3
|
+
const url = parseRepositoryUrl(value);
|
|
4
|
+
assertGitHubRepositoryUrl(url);
|
|
5
|
+
const segments = decodePathSegments(url);
|
|
6
|
+
if (segments.length < 2)
|
|
7
|
+
throw invalidRepositoryUrl();
|
|
8
|
+
const [owner = '', repositorySegment = '', route] = segments;
|
|
9
|
+
const name = repositorySegment.endsWith('.git')
|
|
10
|
+
? repositorySegment.slice(0, -4)
|
|
11
|
+
: repositorySegment;
|
|
12
|
+
assertRepositoryIdentity(owner, name);
|
|
13
|
+
const routeSegments = segments.slice(3);
|
|
14
|
+
if (route === undefined)
|
|
15
|
+
return {
|
|
16
|
+
target: { owner, name, url: `https://github.com/${owner}/${name}` },
|
|
17
|
+
refCandidates: [],
|
|
18
|
+
};
|
|
19
|
+
if (route === 'commit') {
|
|
20
|
+
if (routeSegments.length !== 1)
|
|
21
|
+
throw invalidRepositoryUrl();
|
|
22
|
+
return {
|
|
23
|
+
target: { owner, name, url: `https://github.com/${owner}/${name}` },
|
|
24
|
+
refCandidates: [routeSegments[0] ?? ''],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (route !== 'tree' && route !== 'blob')
|
|
28
|
+
throw invalidRepositoryUrl();
|
|
29
|
+
if (routeSegments.length === 0)
|
|
30
|
+
throw invalidRepositoryUrl();
|
|
31
|
+
return {
|
|
32
|
+
target: { owner, name, url: `https://github.com/${owner}/${name}` },
|
|
33
|
+
refCandidates: createRefCandidates(routeSegments),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Parse a repository URL while preserving the original parsing failure as the cause. */
|
|
37
|
+
function parseRepositoryUrl(value) {
|
|
38
|
+
try {
|
|
39
|
+
return new URL(value);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new Error('Repository URL must be a valid GitHub HTTPS URL.', { cause: error });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Reject non-GitHub origins and embedded credentials while ignoring normal page query/anchor state. */
|
|
46
|
+
function assertGitHubRepositoryUrl(url) {
|
|
47
|
+
if (url.protocol !== 'https:' ||
|
|
48
|
+
url.hostname.toLowerCase() !== 'github.com' ||
|
|
49
|
+
url.username !== '' ||
|
|
50
|
+
url.password !== '')
|
|
51
|
+
throw invalidRepositoryUrl();
|
|
52
|
+
}
|
|
53
|
+
/** Decode normal GitHub path segments and reject malformed encoded paths. */
|
|
54
|
+
function decodePathSegments(url) {
|
|
55
|
+
try {
|
|
56
|
+
return url.pathname
|
|
57
|
+
.split('/')
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.map((segment) => decodeURIComponent(segment));
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw new Error('Repository URL contains an invalid encoded path.', { cause: error });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Build longest-first ref candidates so slash-containing branch/tag names resolve like GitHub URLs. */
|
|
66
|
+
function createRefCandidates(segments) {
|
|
67
|
+
return Array.from({ length: segments.length }, (_, index) => segments.slice(0, segments.length - index).join('/'));
|
|
68
|
+
}
|
|
69
|
+
/** Create the consistent public error for unsupported GitHub URL shapes. */
|
|
70
|
+
function invalidRepositoryUrl() {
|
|
71
|
+
return new Error('Repository URL must be a GitHub repository, tree, blob, or commit HTTPS URL.');
|
|
72
|
+
}
|
|
73
|
+
/** Validate canonical GitHub owner and repository path segments. */
|
|
74
|
+
function assertRepositoryIdentity(owner, name) {
|
|
75
|
+
if (!/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,98}[A-Za-z0-9])?$/u.test(owner))
|
|
76
|
+
throw new Error('GitHub repository owner is invalid.');
|
|
77
|
+
if (!/^[A-Za-z0-9._-]{1,100}$/u.test(name) || name === '.' || name === '..')
|
|
78
|
+
throw new Error('GitHub repository name is invalid.');
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=parseGitHubRepositoryUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseGitHubRepositoryUrl.js","sourceRoot":"","sources":["../../../../src/providers/github/services/parseGitHubRepositoryUrl.ts"],"names":[],"mappings":"AAOA,kGAAkG;AAClG,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,MAAM,GAAG,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACtC,yBAAyB,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,oBAAoB,EAAE,CAAC;IACtD,MAAM,CAAC,KAAK,GAAG,EAAE,EAAE,iBAAiB,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC;IAC7D,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC7C,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC,iBAAiB,CAAC;IACtB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxC,IAAI,KAAK,KAAK,SAAS;QACrB,OAAO;YACL,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,IAAI,IAAI,EAAE,EAAE;YACnE,aAAa,EAAE,EAAE;SAClB,CAAC;IACJ,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvB,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,oBAAoB,EAAE,CAAC;QAC7D,OAAO;YACL,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,IAAI,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C,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kDAAkD,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACxF,CAAC;AACH,CAAC;AAED,wGAAwG;AACxG,SAAS,mBAAmB,CAAC,QAA2B;IACtD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAC1D,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACrD,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,SAAS,oBAAoB;IAC3B,OAAO,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;AACnG,CAAC;AAED,oEAAoE;AACpE,SAAS,wBAAwB,CAAC,KAAa,EAAE,IAAY;IAC3D,IAAI,CAAC,kDAAkD,CAAC,IAAI,CAAC,KAAK,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI;QACzE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GitHubRepositoryRevisionResolutionOptions } from '../definitions/GitHubRepositoryRevisionResolutionOptions.js';
|
|
2
|
+
import type { GitHubRepositoryRevisionResolutionResult } from '../definitions/GitHubRepositoryRevisionResolutionResult.js';
|
|
3
|
+
/** Resolve a GitHub URL to its verified identity and immutable commit without materializing it. */
|
|
4
|
+
export declare function resolveGitHubRepositoryRevisionAsync(options: GitHubRepositoryRevisionResolutionOptions): Promise<GitHubRepositoryRevisionResolutionResult>;
|
|
5
|
+
//# sourceMappingURL=resolveGitHubRepositoryRevisionAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGitHubRepositoryRevisionAsync.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/services/resolveGitHubRepositoryRevisionAsync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,6DAA6D,CAAC;AAC7H,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,4DAA4D,CAAC;AAG3H,mGAAmG;AACnG,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,yCAAyC,GACjD,OAAO,CAAC,wCAAwC,CAAC,CAOnD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createGitHubHttpRepositoryReadGateway } from '../adapters/createGitHubHttpRepositoryReadGateway.js';
|
|
2
|
+
import { resolveGitHubRepositoryRevisionWithGatewayAsync } from './resolveGitHubRepositoryRevisionWithGatewayAsync.js';
|
|
3
|
+
/** Resolve a GitHub URL to its verified identity and immutable commit without materializing it. */
|
|
4
|
+
export function resolveGitHubRepositoryRevisionAsync(options) {
|
|
5
|
+
return resolveGitHubRepositoryRevisionWithGatewayAsync(options, createGitHubHttpRepositoryReadGateway(fetch, {
|
|
6
|
+
authentication: options.authentication ?? 'anonymous',
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=resolveGitHubRepositoryRevisionAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGitHubRepositoryRevisionAsync.js","sourceRoot":"","sources":["../../../../src/providers/github/services/resolveGitHubRepositoryRevisionAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,sDAAsD,CAAC;AAG7G,OAAO,EAAE,+CAA+C,EAAE,MAAM,sDAAsD,CAAC;AAEvH,mGAAmG;AACnG,MAAM,UAAU,oCAAoC,CAClD,OAAkD;IAElD,OAAO,+CAA+C,CACpD,OAAO,EACP,qCAAqC,CAAC,KAAK,EAAE;QAC3C,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,WAAW;KACtD,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GitHubRepositoryRevisionResolutionOptions } from '../definitions/GitHubRepositoryRevisionResolutionOptions.js';
|
|
2
|
+
import type { GitHubRepositoryRevisionResolutionResult } from '../definitions/GitHubRepositoryRevisionResolutionResult.js';
|
|
3
|
+
import type { GitHubRepositoryReadGateway } from '../ports/GitHubRepositoryReadGateway.js';
|
|
4
|
+
/** Resolve a GitHub URL through an injected read gateway for deterministic testing. */
|
|
5
|
+
export declare function resolveGitHubRepositoryRevisionWithGatewayAsync(options: GitHubRepositoryRevisionResolutionOptions, gateway: Pick<GitHubRepositoryReadGateway, 'inspectRepositoryAsync' | 'resolveRevisionAsync'>): Promise<GitHubRepositoryRevisionResolutionResult>;
|
|
6
|
+
//# sourceMappingURL=resolveGitHubRepositoryRevisionWithGatewayAsync.d.ts.map
|
package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGitHubRepositoryRevisionWithGatewayAsync.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,6DAA6D,CAAC;AAC7H,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,4DAA4D,CAAC;AAC3H,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAI3F,uFAAuF;AACvF,wBAAsB,+CAA+C,CACnE,OAAO,EAAE,yCAAyC,EAClD,OAAO,EAAE,IAAI,CAAC,2BAA2B,EAAE,wBAAwB,GAAG,sBAAsB,CAAC,GAC5F,OAAO,CAAC,wCAAwC,CAAC,CAqBnD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseGitHubRepositoryUrl } from './parseGitHubRepositoryUrl.js';
|
|
2
|
+
import { resolveGitHubUrlRevisionAsync } from './resolveGitHubUrlRevisionAsync.js';
|
|
3
|
+
/** Resolve a GitHub URL through an injected read gateway for deterministic testing. */
|
|
4
|
+
export async function resolveGitHubRepositoryRevisionWithGatewayAsync(options, gateway) {
|
|
5
|
+
const parsed = parseGitHubRepositoryUrl(options.url);
|
|
6
|
+
const metadata = await gateway.inspectRepositoryAsync(parsed.target, options.signal);
|
|
7
|
+
const target = { owner: metadata.owner, name: metadata.name, url: metadata.url };
|
|
8
|
+
const revision = await resolveGitHubUrlRevisionAsync(gateway, parsed, target, metadata.defaultBranch, options.signal);
|
|
9
|
+
return {
|
|
10
|
+
repository: {
|
|
11
|
+
id: metadata.id,
|
|
12
|
+
owner: metadata.owner,
|
|
13
|
+
name: metadata.name,
|
|
14
|
+
url: metadata.url,
|
|
15
|
+
defaultBranch: metadata.defaultBranch,
|
|
16
|
+
},
|
|
17
|
+
revision: { commitSha: revision.commitSha, ref: revision.ref },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=resolveGitHubRepositoryRevisionWithGatewayAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGitHubRepositoryRevisionWithGatewayAsync.js","sourceRoot":"","sources":["../../../../src/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,+CAA+C,CACnE,OAAkD,EAClD,OAA6F;IAE7F,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACrF,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACjF,MAAM,QAAQ,GAAG,MAAM,6BAA6B,CAClD,OAAO,EACP,MAAM,EACN,MAAM,EACN,QAAQ,CAAC,aAAa,EACtB,OAAO,CAAC,MAAM,CACf,CAAC;IACF,OAAO;QACL,UAAU,EAAE;YACV,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,GAAG,EAAE,QAAQ,CAAC,GAAG;YACjB,aAAa,EAAE,QAAQ,CAAC,aAAa;SACtC;QACD,QAAQ,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE;KAC/D,CAAC;AACJ,CAAC"}
|
package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGitHubRepositoryRevisionWithGatewayAsync.test.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.ts"],"names":[],"mappings":""}
|
package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { expect, test } from 'bun:test';
|
|
2
|
+
import { GitHubRepositoryDiscoveryError } from '../definitions/GitHubRepositoryDiscoveryResult.js';
|
|
3
|
+
import { resolveGitHubRepositoryRevisionWithGatewayAsync } from './resolveGitHubRepositoryRevisionWithGatewayAsync.js';
|
|
4
|
+
test.each([
|
|
5
|
+
['https://github.com/legacy/example', 'main'],
|
|
6
|
+
['https://github.com/legacy/example/tree/feature/read', 'feature/read'],
|
|
7
|
+
['https://github.com/legacy/example/tree/v1.2.3', 'v1.2.3'],
|
|
8
|
+
['https://github.com/legacy/example/commit/immutable-sha', 'immutable-sha'],
|
|
9
|
+
])('resolves %s to its immutable revision', async (url, expectedRef) => {
|
|
10
|
+
const requests = [];
|
|
11
|
+
const result = await resolveGitHubRepositoryRevisionWithGatewayAsync({ url }, createGateway(requests));
|
|
12
|
+
expect(result).toEqual({
|
|
13
|
+
repository: {
|
|
14
|
+
id: '42',
|
|
15
|
+
owner: 'canonical-owner',
|
|
16
|
+
name: 'renamed-repository',
|
|
17
|
+
url: 'https://github.com/canonical-owner/renamed-repository',
|
|
18
|
+
defaultBranch: 'main',
|
|
19
|
+
},
|
|
20
|
+
revision: { commitSha: 'immutable-sha', ref: expectedRef },
|
|
21
|
+
});
|
|
22
|
+
expect(requests).toEqual([expectedRef]);
|
|
23
|
+
});
|
|
24
|
+
test('preserves typed GitHub failures and forwards cancellation without materialization calls', async () => {
|
|
25
|
+
const permission = new GitHubRepositoryDiscoveryError('permission-denied', 'GitHub denied access to this resource.');
|
|
26
|
+
const rateLimit = new GitHubRepositoryDiscoveryError('rate-limited', 'GitHub rate limit reached. Retry after the reported delay.', 1000);
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
controller.abort();
|
|
29
|
+
await expectFailureAsync(() => resolveGitHubRepositoryRevisionWithGatewayAsync({ url: 'https://github.com/owner/repository' }, createGateway([], permission)), (error) => expect(error).toBe(permission));
|
|
30
|
+
await expectFailureAsync(() => resolveGitHubRepositoryRevisionWithGatewayAsync({ url: 'https://github.com/owner/repository' }, createGateway([], rateLimit)), (error) => expect(error).toBe(rateLimit));
|
|
31
|
+
await expectFailureAsync(() => resolveGitHubRepositoryRevisionWithGatewayAsync({ url: 'https://github.com/owner/repository', signal: controller.signal }, createGateway([])), (error) => expect(error).toMatchObject({ code: 'cancelled' }));
|
|
32
|
+
});
|
|
33
|
+
test('falls back from a missing longest URL ref candidate to a shorter ref', async () => {
|
|
34
|
+
const requests = [];
|
|
35
|
+
const result = await resolveGitHubRepositoryRevisionWithGatewayAsync({ url: 'https://github.com/owner/repository/blob/main/src/index.ts' }, createGateway(requests, refNotFoundError(), 'main'));
|
|
36
|
+
expect(requests).toEqual(['main/src/index.ts', 'main/src', 'main']);
|
|
37
|
+
expect(result.revision.ref).toBe('main');
|
|
38
|
+
});
|
|
39
|
+
test('propagates an unexpected revision error without trying a shorter URL ref candidate', async () => {
|
|
40
|
+
const requests = [];
|
|
41
|
+
const unexpected = new Error('GitHub response schema is invalid.');
|
|
42
|
+
await expectFailureAsync(() => resolveGitHubRepositoryRevisionWithGatewayAsync({ url: 'https://github.com/owner/repository/blob/main/src/index.ts' }, createGateway(requests, unexpected)), (error) => expect(error).toBe(unexpected));
|
|
43
|
+
expect(requests).toEqual(['main/src/index.ts']);
|
|
44
|
+
});
|
|
45
|
+
test.each([
|
|
46
|
+
[
|
|
47
|
+
'rate-limit',
|
|
48
|
+
new GitHubRepositoryDiscoveryError('rate-limited', 'GitHub rate limit reached. Retry after the reported delay.', 1000),
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
'permission denial',
|
|
52
|
+
new GitHubRepositoryDiscoveryError('permission-denied', 'GitHub denied access to this resource.'),
|
|
53
|
+
],
|
|
54
|
+
['timeout', new GitHubRepositoryDiscoveryError('timeout', 'GitHub request timed out.')],
|
|
55
|
+
[
|
|
56
|
+
'cancellation',
|
|
57
|
+
new GitHubRepositoryDiscoveryError('cancelled', 'GitHub repository operation was cancelled.'),
|
|
58
|
+
],
|
|
59
|
+
])('does not fall back after a %s failure', async (_name, failure) => {
|
|
60
|
+
const requests = [];
|
|
61
|
+
await expectFailureAsync(() => resolveGitHubRepositoryRevisionWithGatewayAsync({ url: 'https://github.com/owner/repository/blob/main/src/index.ts' }, createGateway(requests, failure)), (error) => expect(error).toBe(failure));
|
|
62
|
+
expect(requests).toEqual(['main/src/index.ts']);
|
|
63
|
+
});
|
|
64
|
+
test('reports a URL that has no resolvable ref candidates after genuine 404 responses', async () => {
|
|
65
|
+
const requests = [];
|
|
66
|
+
await expectFailureAsync(() => resolveGitHubRepositoryRevisionWithGatewayAsync({ url: 'https://github.com/owner/repository/blob/main/src/index.ts' }, createGateway(requests, refNotFoundError())), (error) => expect(error).toMatchObject({
|
|
67
|
+
message: 'GitHub repository URL does not resolve to a branch, tag, or commit.',
|
|
68
|
+
}));
|
|
69
|
+
expect(requests).toEqual(['main/src/index.ts', 'main/src', 'main']);
|
|
70
|
+
});
|
|
71
|
+
/** Create a read gateway that records only revision requests and rejects materialization methods. */
|
|
72
|
+
function createGateway(requests, revisionFailure, acceptedRef) {
|
|
73
|
+
return {
|
|
74
|
+
inspectRepositoryAsync: (_target, signal) => {
|
|
75
|
+
if (signal?.aborted)
|
|
76
|
+
return Promise.reject(new GitHubRepositoryDiscoveryError('cancelled', 'GitHub repository operation was cancelled.'));
|
|
77
|
+
return Promise.resolve({
|
|
78
|
+
id: '42',
|
|
79
|
+
owner: 'canonical-owner',
|
|
80
|
+
name: 'renamed-repository',
|
|
81
|
+
url: 'https://github.com/canonical-owner/renamed-repository',
|
|
82
|
+
defaultBranch: 'main',
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
resolveRevisionAsync: (_target, ref) => {
|
|
86
|
+
requests.push(ref);
|
|
87
|
+
if (acceptedRef === ref)
|
|
88
|
+
return Promise.resolve({ commitSha: 'immutable-sha', treeSha: 'tree-sha' });
|
|
89
|
+
return revisionFailure === undefined
|
|
90
|
+
? Promise.resolve({ commitSha: 'immutable-sha', treeSha: 'tree-sha' })
|
|
91
|
+
: Promise.reject(revisionFailure);
|
|
92
|
+
},
|
|
93
|
+
readTreeAsync: () => Promise.reject(new Error('Revision resolution must not read a tree.')),
|
|
94
|
+
readFileAsync: () => Promise.reject(new Error('Revision resolution must not read a file.')),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function refNotFoundError() {
|
|
98
|
+
return new GitHubRepositoryDiscoveryError('api-failure', 'GitHub repository revision request failed with HTTP 404.');
|
|
99
|
+
}
|
|
100
|
+
/** Assert an async operation fails with the expected error while keeping rejection handling explicit. */
|
|
101
|
+
async function expectFailureAsync(operation, verify) {
|
|
102
|
+
try {
|
|
103
|
+
await operation();
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
verify(error);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
throw new Error('Expected the operation to fail.');
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=resolveGitHubRepositoryRevisionWithGatewayAsync.test.js.map
|
package/dist/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGitHubRepositoryRevisionWithGatewayAsync.test.js","sourceRoot":"","sources":["../../../../src/providers/github/services/resolveGitHubRepositoryRevisionWithGatewayAsync.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAC;AAEnG,OAAO,EAAE,+CAA+C,EAAE,MAAM,sDAAsD,CAAC;AAEvH,IAAI,CAAC,IAAI,CAAC;IACR,CAAC,mCAAmC,EAAE,MAAM,CAAC;IAC7C,CAAC,qDAAqD,EAAE,cAAc,CAAC;IACvE,CAAC,+CAA+C,EAAE,QAAQ,CAAC;IAC3D,CAAC,wDAAwD,EAAE,eAAe,CAAC;CAC5E,CAAC,CAAC,uCAAuC,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;IACrE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,+CAA+C,CAClE,EAAE,GAAG,EAAE,EACP,aAAa,CAAC,QAAQ,CAAC,CACxB,CAAC;IACF,MAAM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ACvC,aAAa,EACb,0DAA0D,CAC3D,CAAC;AACJ,CAAC;AAED,yGAAyG;AACzG,KAAK,UAAU,kBAAkB,CAC/B,SAAiC,EACjC,MAAgC;IAEhC,IAAI,CAAC;QACH,MAAM,SAAS,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,CAAC;QACd,OAAO;IACT,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GitHubRepositoryReadGateway, GitHubRepositoryReadTarget } from '../ports/GitHubRepositoryReadGateway.js';
|
|
2
|
+
import type { ParsedGitHubRepositoryUrl } from './parseGitHubRepositoryUrl.js';
|
|
3
|
+
/** Resolve URL-derived ref candidates, falling back to the repository default branch. */
|
|
4
|
+
export declare function resolveGitHubUrlRevisionAsync(gateway: Pick<GitHubRepositoryReadGateway, 'resolveRevisionAsync'>, parsed: ParsedGitHubRepositoryUrl, target: GitHubRepositoryReadTarget, defaultBranch: string, signal: AbortSignal | undefined): Promise<{
|
|
5
|
+
readonly commitSha: string;
|
|
6
|
+
readonly treeSha: string;
|
|
7
|
+
readonly ref: string;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=resolveGitHubUrlRevisionAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGitHubUrlRevisionAsync.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/services/resolveGitHubUrlRevisionAsync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE/E,yFAAyF;AACzF,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,IAAI,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,EAClE,MAAM,EAAE,yBAAyB,EACjC,MAAM,EAAE,0BAA0B,EAClC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAUzF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GitHubRepositoryDiscoveryError } from '../definitions/GitHubRepositoryDiscoveryResult.js';
|
|
2
|
+
/** Resolve URL-derived ref candidates, falling back to the repository default branch. */
|
|
3
|
+
export async function resolveGitHubUrlRevisionAsync(gateway, parsed, target, defaultBranch, signal) {
|
|
4
|
+
const candidates = parsed.refCandidates.length === 0 ? [defaultBranch] : parsed.refCandidates;
|
|
5
|
+
for (const ref of candidates) {
|
|
6
|
+
try {
|
|
7
|
+
return { ...(await gateway.resolveRevisionAsync(target, ref, signal)), ref };
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (!isRefNotFoundError(error))
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
throw new Error('GitHub repository URL does not resolve to a branch, tag, or commit.');
|
|
15
|
+
}
|
|
16
|
+
/** Identify only ambiguous URL ref failures that may have a trailing repository path. */
|
|
17
|
+
function isRefNotFoundError(error) {
|
|
18
|
+
return (error instanceof GitHubRepositoryDiscoveryError &&
|
|
19
|
+
error.code === 'api-failure' &&
|
|
20
|
+
error.message.includes('HTTP 404'));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=resolveGitHubUrlRevisionAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGitHubUrlRevisionAsync.js","sourceRoot":"","sources":["../../../../src/providers/github/services/resolveGitHubUrlRevisionAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAC;AAOnG,yFAAyF;AACzF,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAAkE,EAClE,MAAiC,EACjC,MAAkC,EAClC,aAAqB,EACrB,MAA+B;IAE/B,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;IAC9F,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,OAAO,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;QAC/E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;AACzF,CAAC;AAED,yFAAyF;AACzF,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,CACL,KAAK,YAAY,8BAA8B;QAC/C,KAAK,CAAC,IAAI,KAAK,aAAa;QAC5B,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CACnC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/repository",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Standalone repository capability for connecting and managing an app project's source repository.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"knip:check": "ankhorage-knip"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@ankhorage/devtools": "^2.3.
|
|
111
|
+
"@ankhorage/devtools": "^2.3.46",
|
|
112
112
|
"@ankhorage/paradox": "^0.3.6",
|
|
113
113
|
"@types/bun": "^1.4.2",
|
|
114
114
|
"@types/node": "^26.6.6",
|