@unownplain/anthelion-komac 0.0.51 → 0.0.52

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.
Files changed (3) hide show
  1. package/index.d.ts +175 -171
  2. package/index.js +4 -7
  3. package/package.json +9 -9
package/index.d.ts CHANGED
@@ -1,211 +1,215 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Analyze an installer from a URL and return installer analysis information.
4
+ * Reusable Komac client.
5
5
  *
6
- * When the installer is a ZIP, `matches` can be used to select nested installer
7
- * files. Plain strings are matched as case-insensitive substrings, while values
8
- * containing glob metacharacters are matched as glob patterns.
9
- *
10
- * # Errors
11
- *
12
- * Returns `InvalidArg` if `url` is invalid.
13
- * Returns `GenericFailure` if downloading or analyzing the installer fails.
6
+ * A client owns the HTTP connection pools used for GitHub requests and installer downloads.
7
+ * Create one client per process and share it across operations.
14
8
  */
15
- export declare function analyzeInstaller(url: string, matches?: Array<string> | undefined | null): Promise<AnalyzeInstallerResult>
9
+ export declare class Komac {
10
+ /** Create a reusable client. If omitted, `githubToken` falls back to `GITHUB_TOKEN`. */
11
+ constructor(options?: KomacOptions | undefined | null)
12
+ /** Download and analyze one installer artifact. */
13
+ analyzeInstaller(request: AnalyzeInstallerRequest): Promise<AnalyzedArtifact>
14
+ /** Download and analyze several installer artifacts concurrently. */
15
+ analyzeInstallers(request: AnalyzeInstallersRequest): Promise<Array<AnalyzedArtifact>>
16
+ /** Find an existing pull request for a package version. */
17
+ findPullRequest(query: PullRequestQuery): Promise<PullRequest | null>
18
+ /** Fetch normalized notes from a GitHub release. */
19
+ getGithubReleaseNotes(release: GitHubRelease): Promise<string | null>
20
+ /** Generate manifests for an updated package and optionally submit them as a pull request. */
21
+ updatePackage(request: UpdatePackageRequest): Promise<UpdatePackageResult>
22
+ }
23
+
24
+ /** Analysis of one downloaded artifact. */
25
+ export interface AnalyzedArtifact {
26
+ /** Final installer URL used by the downloader. */
27
+ url: string
28
+ /** SHA-256 digest of the downloaded bytes. */
29
+ sha256: string
30
+ /** HTTP last-modified date, when supplied by the server. */
31
+ releaseDate?: string
32
+ /** File version metadata detected in the artifact. */
33
+ versions: DetectedVersions
34
+ /** Installers represented by this artifact, including selected nested installers. */
35
+ installers: Array<AnalyzedInstaller>
36
+ }
37
+
38
+ /** Installer information detected during analysis. */
39
+ export interface AnalyzedInstaller {
40
+ /** Installer locale, if present. */
41
+ locale?: string
42
+ /** Installer architecture. */
43
+ architecture: 'x86' | 'x64' | 'arm' | 'arm64' | 'neutral'
44
+ /** Installer type, if detected. */
45
+ installerType?: string
46
+ /** Nested installer type, if present. */
47
+ nestedInstallerType?: string
48
+ /** Relative paths of nested installer files within an archive. */
49
+ nestedInstallerFiles: Array<string>
50
+ /** Apps and Features / ARP entries detected for this installer. */
51
+ appsAndFeaturesEntries: Array<AppsAndFeaturesEntry>
52
+ /** Install scope, if present. */
53
+ scope?: string
54
+ }
16
55
 
17
- /** Result of the analyze installer operation. */
18
- export interface AnalyzeInstallerResult {
19
- /** Detected installer information. */
20
- analysis: Array<InstallerAnalysis>
21
- /** PE `FileVersion` string from the version info resource, if present. */
22
- fileVersion?: string
23
- /** PE `ProductVersion` string from the version info resource, if present. */
24
- productVersion?: string
56
+ /** Options for analyzing one installer artifact. */
57
+ export interface AnalyzeInstallerRequest {
58
+ /** Artifact to download and analyze. */
59
+ installer: string | InstallerSource
25
60
  }
26
61
 
27
- /** Apps and Features / ARP entry information detected during analysis. */
28
- export interface AppsAndFeaturesEntryAnalysis {
29
- /** Display name registered in Apps and Features, if present. */
62
+ /** Options for analyzing several installer artifacts in one concurrent operation. */
63
+ export interface AnalyzeInstallersRequest {
64
+ /** Artifacts to download and analyze. */
65
+ installers: Array<string | InstallerSource>
66
+ }
67
+
68
+ /** Apps and Features / ARP metadata detected during analysis. */
69
+ export interface AppsAndFeaturesEntry {
30
70
  displayName?: string
31
- /** Publisher registered in Apps and Features, if present. */
32
71
  publisher?: string
33
- /** Display version registered in Apps and Features, if present. */
34
72
  displayVersion?: string
35
- /** Product code registered in Apps and Features, if present. */
36
73
  productCode?: string
37
- /** Upgrade code registered in Apps and Features, if present. */
38
74
  upgradeCode?: string
39
- /** Installer type registered in Apps and Features, if present. */
40
75
  installerType?: string
41
76
  }
42
77
 
43
- /** Existing pull request metadata. */
44
- export interface ExistingPullRequestResult {
45
- /** The URL of the existing pull request */
46
- pullRequestUrl: string
47
- /** The GitHub login of the user or bot that created the pull request */
48
- createdBy: string
49
- /** Whether the pull request was created by the authenticated user */
50
- createdByAuthenticatedUser: boolean
51
- /** The current state of the pull request (`open`, `closed`, or `merged`) */
52
- state: string
53
- /** The pull request creation timestamp in RFC3339 format */
54
- createdAt: string
78
+ /** Newly created pull request links. */
79
+ export interface CreatedPullRequest {
80
+ url: string
81
+ diffUrl: string
55
82
  }
56
83
 
57
- /**
58
- * Get an existing pull request for a package version in winget-pkgs.
59
- *
60
- * # Errors
61
- *
62
- * Returns `InvalidArg` if `package_identifier` or `version` are invalid.
63
- * Returns `GenericFailure` if creating the GitHub client or querying pull requests fails.
64
- */
65
- export declare function getExistingPullRequest(options: GetExistingPullRequestOptions): Promise<ExistingPullRequestResult | null>
84
+ /** Version metadata detected while inspecting an installer. */
85
+ export interface DetectedVersions {
86
+ /** PE `FileVersion`, if present. */
87
+ file?: string
88
+ /** PE `ProductVersion`, if present. */
89
+ product?: string
90
+ }
66
91
 
67
- /** Options for get existing pull request. */
68
- export interface GetExistingPullRequestOptions {
69
- /** The package's unique identifier (e.g. "Microsoft.VisualStudioCode") */
70
- packageIdentifier: string
71
- /** The package version to search for */
72
- version: string
92
+ /** Generated manifest file. */
93
+ export interface GeneratedManifest {
94
+ /** File path within the package repository. */
95
+ path: string
96
+ /** YAML manifest content. */
97
+ yaml: string
98
+ }
99
+
100
+ /** Identifies a GitHub release. */
101
+ export interface GitHubRelease {
102
+ owner: string
103
+ repository: string
104
+ tag: string
105
+ }
106
+
107
+ /** A downloadable installer artifact. */
108
+ export interface InstallerSource {
109
+ /** Installer URL without an encoded architecture suffix. */
110
+ url: string
111
+ /** Override architecture detection for this artifact. */
112
+ architecture?: 'x86' | 'x64' | 'arm' | 'arm64' | 'neutral'
113
+ /** ZIP entry patterns to analyze instead of automatic nested-installer selection. */
114
+ nestedInstallerMatches?: Array<string>
115
+ }
116
+
117
+ /** Configuration shared by every operation performed by a `Komac` client. */
118
+ export interface KomacOptions {
73
119
  /**
74
- * GitHub personal access token with the `public_repo` scope.
75
- * If omitted, `GITHUB_TOKEN` from the environment is used.
120
+ * GitHub token used by repository operations. Defaults to `GITHUB_TOKEN`.
121
+ * Installer analysis does not require a token.
76
122
  */
77
- token?: string
78
- /** Ignore pull requests not created by the authenticated user. */
79
- ignorePullRequestsCreatedByOtherUsers?: boolean
123
+ githubToken?: string
124
+ /**
125
+ * Maximum number of installers downloaded or analyzed concurrently.
126
+ * Defaults to the number of available logical CPUs.
127
+ */
128
+ downloadConcurrency?: number
80
129
  }
81
130
 
82
131
  /**
83
- * Fetch, normalize, and return release notes for a GitHub release tag.
84
- *
85
- * # Errors
132
+ * Parse a YAML document into a JavaScript value.
86
133
  *
87
- * Returns `GenericFailure` if creating the GitHub client or fetching release data fails.
88
- * Returns an error from token resolution when no usable token is available.
89
- */
90
- export declare function getFormattedGithubReleaseNotes(owner: string, repo: string, tag: string, token?: string | undefined | null): Promise<string | null>
91
-
92
- /**
93
- * Convert HTML release notes content to plain text.
134
+ * The core schema resolves YAML scalar types. The failsafe schema preserves all scalars as
135
+ * strings. Duplicate mapping keys are rejected in both modes.
94
136
  *
95
137
  * # Errors
96
138
  *
97
- * Returns `GenericFailure` if the conversion task panics.
139
+ * Throws a `YAMLParseError` if the input is not a single valid YAML document or contains
140
+ * duplicate mapping keys. The error includes `code`, `pos`, `linePos`, and `location` properties.
98
141
  */
99
- export declare function htmlToPlainText(html: string): Promise<string | null>
142
+ export declare function parseYaml(input: string, schema?: 'core' | 'failsafe'): unknown
100
143
 
101
- /** Installer information detected during analysis. */
102
- export interface InstallerAnalysis {
103
- /** Installer locale (if present). */
104
- installerLocale?: string
105
- /** Installer architecture. */
106
- architecture: string
107
- /** Installer type (if detected). */
108
- installerType?: string
109
- /** Nested installer type (if present). */
110
- nestedInstallerType?: string
111
- /** Nested installer files within archives. */
112
- nestedInstallerFiles: Array<NestedInstallerFileAnalysis>
113
- /** Apps and Features / ARP entries detected for this installer. */
114
- appsAndFeaturesEntries: Array<AppsAndFeaturesEntryAnalysis>
115
- /** Install scope (if present). */
116
- scope?: string
117
- /** Installer download URL. */
118
- installerUrl: string
119
- /** Installer SHA-256 hash. */
120
- installerSha256: string
121
- /** Installer release date, if available. */
122
- releaseDate?: string
144
+ /** Existing pull request metadata. */
145
+ export interface PullRequest {
146
+ url: string
147
+ author: string
148
+ authoredByCurrentUser: boolean
149
+ state: 'open' | 'closed' | 'merged'
150
+ /** RFC 3339 creation timestamp. */
151
+ createdAt: string
123
152
  }
124
153
 
125
- /** A single manifest file change. */
126
- export interface ManifestChange {
127
- /** The file path within the winget-pkgs repository */
128
- path: string
129
- /** The YAML content of the manifest */
130
- content: string
154
+ /** Query for an existing WinGet pull request. */
155
+ export interface PullRequestQuery {
156
+ packageIdentifier: string
157
+ version: string
158
+ /** Restrict results to pull requests authored by the authenticated user. */
159
+ authoredByCurrentUserOnly?: boolean
131
160
  }
132
161
 
133
- /**
134
- * Convert Markdown release notes content to plain text.
135
- *
136
- * # Errors
137
- *
138
- * Returns `GenericFailure` if the conversion task panics.
139
- */
140
- export declare function markdownToPlainText(markdown: string): Promise<string | null>
141
-
142
- /** Nested installer file information. */
143
- export interface NestedInstallerFileAnalysis {
144
- /** Relative path to the nested installer file. */
145
- relativeFilePath: string
162
+ /** Release notes fields to apply to the default locale manifest. */
163
+ export interface ReleaseNotesInput {
164
+ text?: string
165
+ url?: string
146
166
  }
147
167
 
148
- /**
149
- * Update an existing package version in winget-pkgs.
150
- *
151
- * # Errors
152
- *
153
- * Returns `InvalidArg` when provided arguments are invalid (identifier, URLs, versions, or selectors).
154
- * Returns `GenericFailure` when downloading installers, analyzing content, loading manifests,
155
- * or creating the pull request fails.
156
- */
157
- export declare function updateVersion(options: UpdateVersionOptions): Promise<UpdateVersionResult>
168
+ /** Convert HTML or Markdown release notes to plain text without blocking the JavaScript event loop. */
169
+ export declare function releaseNotesToPlainText(content: string, format: 'markdown' | 'html'): Promise<string | null>
158
170
 
159
- /** Options for update version. */
160
- export interface UpdateVersionOptions {
161
- /** The package's unique identifier (e.g. "Microsoft.VisualStudioCode") */
162
- packageIdentifier: string
163
- /**
164
- * The new package version.
165
- *
166
- * You can also pass one of:
167
- * - `displayVersion`
168
- * - `productVersion`
169
- * - `fileVersion`
170
- *
171
- * In that case, the version will be resolved from installer analysis.
172
- */
171
+ /** Existing package version to replace. */
172
+ export interface ReplacementSelection {
173
+ target: 'latest' | 'version'
174
+ /** Required only when `target` is `version`. */
175
+ value?: string
176
+ }
177
+
178
+ /** Package version created by an update. */
179
+ export interface UpdatedPackage {
180
+ identifier: string
173
181
  version: string
174
- /** List of installer URLs (may include "|architecture" suffix) */
175
- urls: Array<string>
176
- /**
177
- * ZIP nested installer match patterns used during installer analysis.
178
- * These matches also affect `displayVersion`, `productVersion`, and
179
- * `fileVersion` version selector resolution.
180
- *
181
- * Plain strings are matched as case-insensitive substrings, while values
182
- * containing glob metacharacters are matched as glob patterns.
183
- */
184
- installerMatches?: Array<string>
185
- /** URL to the release notes */
186
- releaseNotesUrl?: string
187
- /** Release notes text for the manifest */
188
- releaseNotes?: string
189
- /** Run without submitting a PR */
190
- dryRun?: boolean
191
- /** Version to replace (use "latest" for the latest version) */
192
- replace?: string
193
- /** Look for the package under fonts instead of probing manifests first */
194
- font?: boolean
195
- /** GitHub personal access token with the `public_repo` scope */
196
- token?: string
197
- }
198
-
199
- /** Result of the update version operation. */
200
- export interface UpdateVersionResult {
201
- /** The URL of the created pull request, if submitted */
202
- pullRequestUrl?: string
203
- /** The winget-diff view URL for the created pull request, if submitted */
204
- diffViewUrl?: string
205
- /** The generated manifest changes as a list of (path, content) pairs */
206
- changes: Array<ManifestChange>
207
- /** The package identifier that was updated */
182
+ }
183
+
184
+ /** Update an existing package using newly published installers. */
185
+ export interface UpdatePackageRequest {
186
+ /** Package identifier, for example `Microsoft.VisualStudioCode`. */
208
187
  packageIdentifier: string
209
- /** The version that was created */
210
- version: string
188
+ /** How to determine the new package version. */
189
+ version: string | { source: 'explicit'; value: string } | { source: 'display' | 'product' | 'file' }
190
+ /** New installer artifacts. */
191
+ installers: Array<string | InstallerSource>
192
+ /** Release notes fields for the default locale manifest. */
193
+ releaseNotes?: ReleaseNotesInput
194
+ /** Existing version to remove in the same pull request. */
195
+ replace?: { target: 'latest' } | { target: 'version'; value: string }
196
+ /** Package layout. Defaults to `auto`, which probes standard manifests before fonts. */
197
+ packageKind?: 'auto' | 'standard' | 'font'
198
+ /** Generate manifests locally or submit them as a pull request. */
199
+ mode: 'generate' | 'submit'
200
+ }
201
+
202
+ /** Result of generating or submitting a package update. */
203
+ export interface UpdatePackageResult {
204
+ package: UpdatedPackage
205
+ manifests: Array<GeneratedManifest>
206
+ /** Present only when `mode` was `submit` and pull-request creation succeeded. */
207
+ pullRequest?: CreatedPullRequest
208
+ }
209
+
210
+ /** Explicit or installer-derived package version selection. */
211
+ export interface VersionSelection {
212
+ source: 'explicit' | 'display' | 'product' | 'file'
213
+ /** Required only when `source` is `explicit`. */
214
+ value?: string
211
215
  }
package/index.js CHANGED
@@ -590,10 +590,7 @@ if (!nativeBinding) {
590
590
  throw new Error(`Failed to load native binding`)
591
591
  }
592
592
 
593
- const { analyzeInstaller, getExistingPullRequest, getFormattedGithubReleaseNotes, htmlToPlainText, markdownToPlainText, updateVersion } = nativeBinding
594
- export { analyzeInstaller }
595
- export { getExistingPullRequest }
596
- export { getFormattedGithubReleaseNotes }
597
- export { htmlToPlainText }
598
- export { markdownToPlainText }
599
- export { updateVersion }
593
+ const { Komac, parseYaml, releaseNotesToPlainText } = nativeBinding
594
+ export { Komac }
595
+ export { parseYaml }
596
+ export { releaseNotesToPlainText }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unownplain/anthelion-komac",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "komac JS bindings for Anthelion",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -41,13 +41,13 @@
41
41
  "node": ">=22.0.0"
42
42
  },
43
43
  "optionalDependencies": {
44
- "@unownplain/anthelion-komac-win32-x64-msvc": "0.0.51",
45
- "@unownplain/anthelion-komac-darwin-x64": "0.0.51",
46
- "@unownplain/anthelion-komac-linux-x64-gnu": "0.0.51",
47
- "@unownplain/anthelion-komac-linux-x64-musl": "0.0.51",
48
- "@unownplain/anthelion-komac-darwin-arm64": "0.0.51",
49
- "@unownplain/anthelion-komac-linux-arm64-gnu": "0.0.51",
50
- "@unownplain/anthelion-komac-linux-arm64-musl": "0.0.51",
51
- "@unownplain/anthelion-komac-win32-arm64-msvc": "0.0.51"
44
+ "@unownplain/anthelion-komac-win32-x64-msvc": "0.0.52",
45
+ "@unownplain/anthelion-komac-darwin-x64": "0.0.52",
46
+ "@unownplain/anthelion-komac-linux-x64-gnu": "0.0.52",
47
+ "@unownplain/anthelion-komac-linux-x64-musl": "0.0.52",
48
+ "@unownplain/anthelion-komac-darwin-arm64": "0.0.52",
49
+ "@unownplain/anthelion-komac-linux-arm64-gnu": "0.0.52",
50
+ "@unownplain/anthelion-komac-linux-arm64-musl": "0.0.52",
51
+ "@unownplain/anthelion-komac-win32-arm64-msvc": "0.0.52"
52
52
  }
53
53
  }