@enhansome/core 1.8.0 → 1.8.1
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/dist/github.d.ts +6 -0
- package/dist/github.js +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/markdown.d.ts +2 -1
- package/dist/markdown.js +2 -1
- package/dist/orchestrator.d.ts +1 -0
- package/dist/orchestrator.js +2 -2
- package/package.json +1 -1
package/dist/github.d.ts
CHANGED
|
@@ -76,6 +76,12 @@ export interface MakeOctokitOptions {
|
|
|
76
76
|
*/
|
|
77
77
|
export declare function makeOctokit(token: string, { log, maxRetries, maxWaitSeconds, throttle, }?: MakeOctokitOptions): GithubClient;
|
|
78
78
|
export declare function getRepoInfo(octokit: GithubClient, owner: string, repo: string): Promise<RepoInfoDetails>;
|
|
79
|
+
/**
|
|
80
|
+
* The repo's numeric GitHub id, for the JSON metadata — consumers key stable
|
|
81
|
+
* node ids on it. Returns null (logged) instead of failing the run: the id is
|
|
82
|
+
* metadata, not a gate; consumers fall back when it is missing.
|
|
83
|
+
*/
|
|
84
|
+
export declare function getRepoId(octokit: GithubClient, owner: string, repo: string): Promise<null | number>;
|
|
79
85
|
export declare function getReadme(octokit: GithubClient, owner: string, repo: string, format?: 'html' | 'raw'): Promise<string>;
|
|
80
86
|
/** Root file/directory names — the compile-manifest gate reads them to tell a
|
|
81
87
|
* directory of resources from a repo that IS the deliverable. A `path: ''`
|
package/dist/github.js
CHANGED
|
@@ -82,6 +82,20 @@ export async function getRepoInfo(octokit, owner, repo) {
|
|
|
82
82
|
topics: data.topics ?? [],
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* The repo's numeric GitHub id, for the JSON metadata — consumers key stable
|
|
87
|
+
* node ids on it. Returns null (logged) instead of failing the run: the id is
|
|
88
|
+
* metadata, not a gate; consumers fall back when it is missing.
|
|
89
|
+
*/
|
|
90
|
+
export async function getRepoId(octokit, owner, repo) {
|
|
91
|
+
try {
|
|
92
|
+
return (await getRepoInfo(octokit, owner, repo)).id;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
octokit.log.error(`Failed to fetch repo id for ${owner}/${repo}: ${formatRequestError(error)}`);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
85
99
|
export async function getReadme(octokit, owner, repo, format = 'raw') {
|
|
86
100
|
octokit.log.debug(`Fetching ${format} README for ${owner}/${repo}`);
|
|
87
101
|
const response = await octokit.rest.repos.getReadme({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { formatRequestError, getLatestCommitSha, getReadme, getRepoInfo, getRootEntryNames, makeOctokit, parseGitHubUrl, parseOwnerRepo, } from './github.js';
|
|
1
|
+
export { formatRequestError, getLatestCommitSha, getReadme, getRepoId, getRepoInfo, getRootEntryNames, makeOctokit, parseGitHubUrl, parseOwnerRepo, } from './github.js';
|
|
2
2
|
export type { GithubClient, MakeOctokitOptions, RepoIdentifier, RepoInfoDetails, ThrottleOptions, } from './github.js';
|
|
3
3
|
export type { Logger } from './logger.js';
|
|
4
4
|
export { consoleLog, silentLog } from './logger.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { formatRequestError, getLatestCommitSha, getReadme, getRepoInfo, getRootEntryNames, makeOctokit, parseGitHubUrl, parseOwnerRepo, } from './github.js';
|
|
1
|
+
export { formatRequestError, getLatestCommitSha, getReadme, getRepoId, getRepoInfo, getRootEntryNames, makeOctokit, parseGitHubUrl, parseOwnerRepo, } from './github.js';
|
|
2
2
|
export { consoleLog, silentLog } from './logger.js';
|
|
3
3
|
export { toRepoInfo } from './markdown.js';
|
|
4
4
|
export { enhance } from './orchestrator.js';
|
package/dist/markdown.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface JsonMetadata {
|
|
|
45
45
|
enhanced_repository_description: null | string;
|
|
46
46
|
last_updated: string;
|
|
47
47
|
original_repository: string;
|
|
48
|
+
original_repository_id: null | number;
|
|
48
49
|
original_repository_sha: null | string;
|
|
49
50
|
title: string;
|
|
50
51
|
}
|
|
@@ -53,7 +54,7 @@ export interface JsonSection {
|
|
|
53
54
|
items: JsonNode[];
|
|
54
55
|
title: string;
|
|
55
56
|
}
|
|
56
|
-
export declare function processMarkdownContent(originalContent: string, token: string, replacements: ReplacementRule[] | undefined, sortOptions: SortOptions | undefined, originalRepository: string, relativeLinkPrefix?: string, enhancedRepository?: string, enhancedRepositoryDescription?: string, originalRepositorySha?: string, now?: Date, log?: Logger): Promise<{
|
|
57
|
+
export declare function processMarkdownContent(originalContent: string, token: string, replacements: ReplacementRule[] | undefined, sortOptions: SortOptions | undefined, originalRepository: string, relativeLinkPrefix?: string, enhancedRepository?: string, enhancedRepositoryDescription?: string, originalRepositorySha?: string, originalRepositoryId?: number, now?: Date, log?: Logger): Promise<{
|
|
57
58
|
finalContent: string;
|
|
58
59
|
jsonData: JsonOutput;
|
|
59
60
|
}>;
|
package/dist/markdown.js
CHANGED
|
@@ -79,7 +79,7 @@ async function fetchTargetData(urls, repos) {
|
|
|
79
79
|
log.info(`Target fetch: ${repoInfoMap.size}/${urls.size} repo-info ok in ${Date.now() - fetchStart}ms (concurrency ${FETCH_CONCURRENCY}).`);
|
|
80
80
|
return repoInfoMap;
|
|
81
81
|
}
|
|
82
|
-
export async function processMarkdownContent(originalContent, token, replacements = [], sortOptions = { by: '', minLinks: 2 }, originalRepository, relativeLinkPrefix = '', enhancedRepository, enhancedRepositoryDescription, originalRepositorySha, now = new Date(), log = consoleLog) {
|
|
82
|
+
export async function processMarkdownContent(originalContent, token, replacements = [], sortOptions = { by: '', minLinks: 2 }, originalRepository, relativeLinkPrefix = '', enhancedRepository, enhancedRepositoryDescription, originalRepositorySha, originalRepositoryId, now = new Date(), log = consoleLog) {
|
|
83
83
|
const repos = createRepoInfoLookup(token, log);
|
|
84
84
|
const brandingEnabled = replacements.some(rule => rule.type === 'branding');
|
|
85
85
|
const contentAfterReplacements = applyTextReplacements(originalContent, replacements.filter(rule => rule.type !== 'branding'), log);
|
|
@@ -99,6 +99,7 @@ export async function processMarkdownContent(originalContent, token, replacement
|
|
|
99
99
|
const metadata = {
|
|
100
100
|
last_updated: now.toISOString(),
|
|
101
101
|
original_repository: originalRepository.trim(),
|
|
102
|
+
original_repository_id: originalRepositoryId ?? null,
|
|
102
103
|
original_repository_sha: (originalRepositorySha?.trim() ?? '') || null,
|
|
103
104
|
enhanced_repository: (enhancedRepository?.trim() ?? '') || null,
|
|
104
105
|
enhanced_repository_description: (enhancedRepositoryDescription?.trim() ?? '') || null,
|
package/dist/orchestrator.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface EnhanceOptions {
|
|
|
9
9
|
log?: Logger;
|
|
10
10
|
now?: Date;
|
|
11
11
|
originalRepository: string;
|
|
12
|
+
originalRepositoryId?: number;
|
|
12
13
|
originalRepositorySha?: string;
|
|
13
14
|
relativeLinkPrefix?: string;
|
|
14
15
|
/** Text substitutions applied to the source before it is parsed. */
|
package/dist/orchestrator.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { processMarkdownContent, } from './markdown.js';
|
|
2
2
|
export async function enhance(options) {
|
|
3
|
-
const { content, disableBranding = false, log, now = new Date(), originalRepository, originalRepositorySha, relativeLinkPrefix = '', replacements = [], sortBy = '', enhancedRepository, enhancedRepositoryDescription, token, } = options;
|
|
3
|
+
const { content, disableBranding = false, log, now = new Date(), originalRepository, originalRepositoryId, originalRepositorySha, relativeLinkPrefix = '', replacements = [], sortBy = '', enhancedRepository, enhancedRepositoryDescription, token, } = options;
|
|
4
4
|
// Branding is an internal rule prepended to the caller's own; build a fresh
|
|
5
5
|
// array so the caller's `replacements` is never mutated.
|
|
6
6
|
const branding = { type: 'branding' };
|
|
@@ -9,7 +9,7 @@ export async function enhance(options) {
|
|
|
9
9
|
by: sortBy,
|
|
10
10
|
minLinks: 2,
|
|
11
11
|
};
|
|
12
|
-
const { finalContent, jsonData } = await processMarkdownContent(content, token, rules, sortOptions, originalRepository, relativeLinkPrefix, enhancedRepository, enhancedRepositoryDescription, originalRepositorySha, now, log);
|
|
12
|
+
const { finalContent, jsonData } = await processMarkdownContent(content, token, rules, sortOptions, originalRepository, relativeLinkPrefix, enhancedRepository, enhancedRepositoryDescription, originalRepositorySha, originalRepositoryId, now, log);
|
|
13
13
|
return {
|
|
14
14
|
finalContent,
|
|
15
15
|
jsonData,
|