@unownplain/anthelion-komac 0.0.51 → 0.0.53

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 +13 -13
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
+ /** 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
+ /** OpenType name ID 5, normalized for package-version use, if present. */
91
+ font?: string
92
+ }
66
93
 
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
94
+ /** Generated manifest file. */
95
+ export interface GeneratedManifest {
96
+ /** File path within the package repository. */
97
+ path: string
98
+ /** YAML manifest content. */
99
+ yaml: string
100
+ }
101
+
102
+ /** Identifies a GitHub release. */
103
+ export interface GitHubRelease {
104
+ owner: string
105
+ repository: string
106
+ tag: string
107
+ }
108
+
109
+ /** A downloadable installer artifact. */
110
+ export interface InstallerSource {
111
+ /** Installer URL without an encoded architecture suffix. */
112
+ url: string
113
+ /** Override architecture detection for this artifact. */
114
+ architecture?: 'x86' | 'x64' | 'arm' | 'arm64' | 'neutral'
115
+ /** ZIP entry patterns to analyze instead of automatic nested-installer selection. */
116
+ nestedInstallerMatches?: Array<string>
117
+ }
118
+
119
+ /** Configuration shared by every operation performed by a `Komac` client. */
120
+ export interface KomacOptions {
73
121
  /**
74
- * GitHub personal access token with the `public_repo` scope.
75
- * If omitted, `GITHUB_TOKEN` from the environment is used.
122
+ * GitHub token used by repository operations. Defaults to `GITHUB_TOKEN`.
123
+ * Installer analysis does not require a token.
76
124
  */
77
- token?: string
78
- /** Ignore pull requests not created by the authenticated user. */
79
- ignorePullRequestsCreatedByOtherUsers?: boolean
125
+ githubToken?: string
126
+ /**
127
+ * Maximum number of installers downloaded or analyzed concurrently.
128
+ * Defaults to the number of available logical CPUs.
129
+ */
130
+ downloadConcurrency?: number
80
131
  }
81
132
 
82
133
  /**
83
- * Fetch, normalize, and return release notes for a GitHub release tag.
84
- *
85
- * # Errors
134
+ * Parse a YAML document into a JavaScript value.
86
135
  *
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.
136
+ * The core schema resolves YAML scalar types. The failsafe schema preserves all scalars as
137
+ * strings. Duplicate mapping keys are rejected in both modes.
94
138
  *
95
139
  * # Errors
96
140
  *
97
- * Returns `GenericFailure` if the conversion task panics.
141
+ * Throws a `YAMLParseError` if the input is not a single valid YAML document or contains
142
+ * duplicate mapping keys. The error includes `code`, `pos`, `linePos`, and `location` properties.
98
143
  */
99
- export declare function htmlToPlainText(html: string): Promise<string | null>
144
+ export declare function parseYaml(input: string, schema?: 'core' | 'failsafe'): unknown
100
145
 
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
146
+ /** Existing pull request metadata. */
147
+ export interface PullRequest {
148
+ url: string
149
+ author: string
150
+ authoredByCurrentUser: boolean
151
+ state: 'open' | 'closed' | 'merged'
152
+ /** RFC 3339 creation timestamp. */
153
+ createdAt: string
123
154
  }
124
155
 
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
156
+ /** Query for an existing WinGet pull request. */
157
+ export interface PullRequestQuery {
158
+ packageIdentifier: string
159
+ version: string
160
+ /** Restrict results to pull requests authored by the authenticated user. */
161
+ authoredByCurrentUserOnly?: boolean
131
162
  }
132
163
 
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
164
+ /** Release notes fields to apply to the default locale manifest. */
165
+ export interface ReleaseNotesInput {
166
+ text?: string
167
+ url?: string
146
168
  }
147
169
 
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>
170
+ /** Convert HTML or Markdown release notes to plain text without blocking the JavaScript event loop. */
171
+ export declare function releaseNotesToPlainText(content: string, format: 'markdown' | 'html'): Promise<string | null>
158
172
 
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
- */
173
+ /** Existing package version to replace. */
174
+ export interface ReplacementSelection {
175
+ target: 'latest' | 'version'
176
+ /** Required only when `target` is `version`. */
177
+ value?: string
178
+ }
179
+
180
+ /** Package version created by an update. */
181
+ export interface UpdatedPackage {
182
+ identifier: string
173
183
  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 */
184
+ }
185
+
186
+ /** Update an existing package using newly published installers. */
187
+ export interface UpdatePackageRequest {
188
+ /** Package identifier, for example `Microsoft.VisualStudioCode`. */
208
189
  packageIdentifier: string
209
- /** The version that was created */
210
- version: string
190
+ /** How to determine the new package version. */
191
+ version: string | { source: 'display' | 'product' | 'file' | 'fontVersion' }
192
+ /** New installer artifacts. */
193
+ installers: Array<string | InstallerSource>
194
+ /** Release notes fields for the default locale manifest. */
195
+ releaseNotes?: ReleaseNotesInput
196
+ /** Existing version to remove in the same pull request. */
197
+ replace?: { target: 'latest' } | { target: 'version'; value: string }
198
+ /** Package layout. Defaults to `auto`, which probes standard manifests before fonts. */
199
+ packageKind?: 'auto' | 'standard' | 'font'
200
+ /** Generate manifests locally or submit them as a pull request. */
201
+ mode: 'generate' | 'submit'
202
+ }
203
+
204
+ /** Result of generating or submitting a package update. */
205
+ export interface UpdatePackageResult {
206
+ package: UpdatedPackage
207
+ manifests: Array<GeneratedManifest>
208
+ /** Present only when `mode` was `submit` and pull-request creation succeeded. */
209
+ pullRequest?: CreatedPullRequest
210
+ }
211
+
212
+ /** Installer-derived package version selection. */
213
+ export interface VersionSelection {
214
+ source: 'display' | 'product' | 'file' | 'fontVersion'
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.53",
4
4
  "description": "komac JS bindings for Anthelion",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -15,14 +15,14 @@
15
15
  "main": "index.js",
16
16
  "scripts": {
17
17
  "artifacts": "napi artifacts",
18
- "build": "napi build --platform --release --esm --strip",
19
- "build:debug": "napi build --platform --esm",
18
+ "build": "napi build --platform --release --no-default-features --features node --esm --strip",
19
+ "build:debug": "napi build --platform --no-default-features --features node --esm",
20
20
  "prepublishOnly": "napi prepublish -t npm --no-gh-release",
21
- "preversion": "napi build --platform && git add .",
21
+ "preversion": "bun run build && git add .",
22
22
  "version": "napi version"
23
23
  },
24
24
  "devDependencies": {
25
- "@napi-rs/cli": "3.7.3"
25
+ "@napi-rs/cli": "3.7.4"
26
26
  },
27
27
  "napi": {
28
28
  "binaryName": "anthelion-komac",
@@ -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.53",
45
+ "@unownplain/anthelion-komac-darwin-x64": "0.0.53",
46
+ "@unownplain/anthelion-komac-linux-x64-gnu": "0.0.53",
47
+ "@unownplain/anthelion-komac-linux-x64-musl": "0.0.53",
48
+ "@unownplain/anthelion-komac-darwin-arm64": "0.0.53",
49
+ "@unownplain/anthelion-komac-linux-arm64-gnu": "0.0.53",
50
+ "@unownplain/anthelion-komac-linux-arm64-musl": "0.0.53",
51
+ "@unownplain/anthelion-komac-win32-arm64-msvc": "0.0.53"
52
52
  }
53
53
  }