@start9labs/start-sdk 0.4.0-beta.50 → 0.4.0-beta.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 (165) hide show
  1. package/base/lib/Effects.d.ts +4 -0
  2. package/base/lib/actions/input/builder/inputSpec.d.ts +129 -8
  3. package/base/lib/actions/input/builder/inputSpec.js +223 -13
  4. package/base/lib/actions/input/builder/inputSpec.js.map +1 -1
  5. package/base/lib/actions/input/builder/inputSpecTools.d.ts +3 -3
  6. package/base/lib/actions/input/builder/list.d.ts +24 -3
  7. package/base/lib/actions/input/builder/list.js +26 -5
  8. package/base/lib/actions/input/builder/list.js.map +1 -1
  9. package/base/lib/actions/input/builder/value.d.ts +70 -16
  10. package/base/lib/actions/input/builder/value.js +89 -34
  11. package/base/lib/actions/input/builder/value.js.map +1 -1
  12. package/base/lib/actions/input/builder/variants.d.ts +14 -3
  13. package/base/lib/actions/input/builder/variants.js +22 -7
  14. package/base/lib/actions/input/builder/variants.js.map +1 -1
  15. package/base/lib/actions/input/inputSpecConstants.d.ts +203 -5
  16. package/base/lib/actions/input/inputSpecConstants.js +118 -38
  17. package/base/lib/actions/input/inputSpecConstants.js.map +1 -1
  18. package/base/lib/actions/input/inputSpecTypes.d.ts +99 -0
  19. package/base/lib/actions/input/inputSpecTypes.js +6 -1
  20. package/base/lib/actions/input/inputSpecTypes.js.map +1 -1
  21. package/base/lib/actions/setupActions.d.ts +6 -3
  22. package/base/lib/actions/setupActions.js +7 -4
  23. package/base/lib/actions/setupActions.js.map +1 -1
  24. package/base/lib/exver/index.d.ts +233 -2
  25. package/base/lib/exver/index.js +197 -3
  26. package/base/lib/exver/index.js.map +1 -1
  27. package/base/lib/index.d.ts +23 -1
  28. package/base/lib/index.js +4 -2
  29. package/base/lib/index.js.map +1 -1
  30. package/base/lib/inits/setupInit.d.ts +17 -0
  31. package/base/lib/inits/setupInit.js +7 -0
  32. package/base/lib/inits/setupInit.js.map +1 -1
  33. package/base/lib/inits/setupUninit.d.ts +12 -0
  34. package/base/lib/inits/setupUninit.js +7 -0
  35. package/base/lib/inits/setupUninit.js.map +1 -1
  36. package/base/lib/interfaces/Host.js +2 -4
  37. package/base/lib/interfaces/Host.js.map +1 -1
  38. package/base/lib/osBindings/GetOutboundGatewayParams.d.ts +4 -0
  39. package/base/lib/osBindings/GetOutboundGatewayParams.js +3 -0
  40. package/base/lib/osBindings/GetOutboundGatewayParams.js.map +1 -0
  41. package/base/lib/osBindings/ServerHostname.d.ts +1 -0
  42. package/base/lib/osBindings/ServerHostname.js +4 -0
  43. package/base/lib/osBindings/ServerHostname.js.map +1 -0
  44. package/base/lib/osBindings/ServerInfo.d.ts +1 -0
  45. package/base/lib/osBindings/SetServerHostnameParams.d.ts +4 -0
  46. package/base/lib/osBindings/SetServerHostnameParams.js +4 -0
  47. package/base/lib/osBindings/SetServerHostnameParams.js.map +1 -0
  48. package/base/lib/osBindings/SetupExecuteParams.d.ts +3 -1
  49. package/base/lib/osBindings/SmtpSecurity.d.ts +1 -0
  50. package/base/lib/osBindings/SmtpSecurity.js +4 -0
  51. package/base/lib/osBindings/SmtpSecurity.js.map +1 -0
  52. package/base/lib/osBindings/SmtpValue.d.ts +4 -2
  53. package/base/lib/osBindings/SmtpValue.js +0 -1
  54. package/base/lib/osBindings/SmtpValue.js.map +1 -1
  55. package/base/lib/osBindings/StartOsRecoveryInfo.d.ts +2 -2
  56. package/base/lib/osBindings/TestSmtpParams.d.ts +4 -2
  57. package/base/lib/osBindings/TestSmtpParams.js +0 -1
  58. package/base/lib/osBindings/TestSmtpParams.js.map +1 -1
  59. package/base/lib/osBindings/index.d.ts +4 -1
  60. package/base/lib/s9pk/index.d.ts +66 -0
  61. package/base/lib/s9pk/index.js +70 -1
  62. package/base/lib/s9pk/index.js.map +1 -1
  63. package/base/lib/types.d.ts +68 -2
  64. package/base/lib/types.js +14 -0
  65. package/base/lib/types.js.map +1 -1
  66. package/base/lib/util/GetOutboundGateway.d.ts +30 -0
  67. package/base/lib/util/GetOutboundGateway.js +90 -0
  68. package/base/lib/util/GetOutboundGateway.js.map +1 -0
  69. package/base/lib/util/asError.d.ts +8 -0
  70. package/base/lib/util/asError.js +8 -0
  71. package/base/lib/util/asError.js.map +1 -1
  72. package/base/lib/util/deepEqual.d.ts +15 -0
  73. package/base/lib/util/deepEqual.js +16 -2
  74. package/base/lib/util/deepEqual.js.map +1 -1
  75. package/base/lib/util/deepMerge.d.ts +18 -0
  76. package/base/lib/util/deepMerge.js +18 -0
  77. package/base/lib/util/deepMerge.js.map +1 -1
  78. package/base/lib/util/getDefaultString.d.ts +8 -0
  79. package/base/lib/util/getDefaultString.js +8 -0
  80. package/base/lib/util/getDefaultString.js.map +1 -1
  81. package/base/lib/util/graph.d.ts +57 -0
  82. package/base/lib/util/graph.js +47 -0
  83. package/base/lib/util/graph.js.map +1 -1
  84. package/base/lib/util/inMs.d.ts +15 -0
  85. package/base/lib/util/inMs.js +15 -0
  86. package/base/lib/util/inMs.js.map +1 -1
  87. package/base/lib/util/index.d.ts +1 -0
  88. package/base/lib/util/index.js +3 -1
  89. package/base/lib/util/index.js.map +1 -1
  90. package/base/lib/util/ip.d.ts +81 -0
  91. package/base/lib/util/ip.js +81 -0
  92. package/base/lib/util/ip.js.map +1 -1
  93. package/base/lib/util/once.d.ts +13 -0
  94. package/base/lib/util/once.js +13 -0
  95. package/base/lib/util/once.js.map +1 -1
  96. package/base/lib/util/patterns.d.ts +11 -0
  97. package/base/lib/util/patterns.js +11 -0
  98. package/base/lib/util/patterns.js.map +1 -1
  99. package/base/lib/util/regexes.d.ts +38 -0
  100. package/base/lib/util/regexes.js +38 -0
  101. package/base/lib/util/regexes.js.map +1 -1
  102. package/base/lib/util/splitCommand.d.ts +14 -0
  103. package/base/lib/util/splitCommand.js +15 -2
  104. package/base/lib/util/splitCommand.js.map +1 -1
  105. package/base/lib/util/stringFromStdErrOut.d.ts +7 -0
  106. package/base/lib/util/stringFromStdErrOut.js +7 -0
  107. package/base/lib/util/stringFromStdErrOut.js.map +1 -1
  108. package/base/lib/util/typeHelpers.d.ts +35 -0
  109. package/base/lib/util/typeHelpers.js +7 -0
  110. package/base/lib/util/typeHelpers.js.map +1 -1
  111. package/package/lib/StartSdk.d.ts +330 -3
  112. package/package/lib/StartSdk.js +143 -1
  113. package/package/lib/StartSdk.js.map +1 -1
  114. package/package/lib/backup/Backups.d.ts +71 -0
  115. package/package/lib/backup/Backups.js +69 -0
  116. package/package/lib/backup/Backups.js.map +1 -1
  117. package/package/lib/backup/setupBackups.d.ts +14 -0
  118. package/package/lib/backup/setupBackups.js +9 -0
  119. package/package/lib/backup/setupBackups.js.map +1 -1
  120. package/package/lib/health/HealthCheck.d.ts +16 -0
  121. package/package/lib/health/HealthCheck.js +16 -2
  122. package/package/lib/health/HealthCheck.js.map +1 -1
  123. package/package/lib/health/checkFns/HealthCheckResult.d.ts +6 -0
  124. package/package/lib/health/checkFns/index.d.ts +8 -0
  125. package/package/lib/health/checkFns/index.js +8 -0
  126. package/package/lib/health/checkFns/index.js.map +1 -1
  127. package/package/lib/index.d.ts +2 -2
  128. package/package/lib/index.js +2 -2
  129. package/package/lib/index.js.map +1 -1
  130. package/package/lib/mainFn/CommandController.d.ts +29 -0
  131. package/package/lib/mainFn/CommandController.js +29 -0
  132. package/package/lib/mainFn/CommandController.js.map +1 -1
  133. package/package/lib/mainFn/Daemon.d.ts +38 -2
  134. package/package/lib/mainFn/Daemon.js +38 -2
  135. package/package/lib/mainFn/Daemon.js.map +1 -1
  136. package/package/lib/mainFn/Daemons.d.ts +31 -0
  137. package/package/lib/mainFn/Daemons.js +13 -0
  138. package/package/lib/mainFn/Daemons.js.map +1 -1
  139. package/package/lib/mainFn/Mounts.d.ts +38 -0
  140. package/package/lib/mainFn/Mounts.js +38 -0
  141. package/package/lib/mainFn/Mounts.js.map +1 -1
  142. package/package/lib/mainFn/index.d.ts +1 -0
  143. package/package/lib/mainFn/index.js +1 -0
  144. package/package/lib/mainFn/index.js.map +1 -1
  145. package/package/lib/manifest/setupManifest.d.ts +9 -0
  146. package/package/lib/manifest/setupManifest.js +9 -0
  147. package/package/lib/manifest/setupManifest.js.map +1 -1
  148. package/package/lib/test/output.d.ts +2 -2
  149. package/package/lib/test/output.js +418 -329
  150. package/package/lib/test/output.js.map +1 -1
  151. package/package/lib/test/output.sdk.d.ts +193 -2
  152. package/package/lib/util/SubContainer.d.ts +46 -0
  153. package/package/lib/util/SubContainer.js +10 -0
  154. package/package/lib/util/SubContainer.js.map +1 -1
  155. package/package/lib/util/fileHelper.d.ts +43 -10
  156. package/package/lib/util/fileHelper.js +13 -11
  157. package/package/lib/util/fileHelper.js.map +1 -1
  158. package/package/lib/version/VersionGraph.d.ts +64 -13
  159. package/package/lib/version/VersionGraph.js +64 -18
  160. package/package/lib/version/VersionGraph.js.map +1 -1
  161. package/package/lib/version/VersionInfo.d.ts +17 -0
  162. package/package/lib/version/VersionInfo.js +12 -0
  163. package/package/lib/version/VersionInfo.js.map +1 -1
  164. package/package/package.json +9 -8
  165. package/package.json +9 -8
@@ -1,7 +1,38 @@
1
1
  import { DeepMap } from 'deep-equality-data-structures';
2
2
  import * as P from './exver';
3
+ /**
4
+ * Compile-time utility type that validates a version string literal conforms to semver format.
5
+ *
6
+ * Resolves to `unknown` if valid, `never` if invalid. Used with {@link testTypeVersion}.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * type Valid = ValidateVersion<"1.2.3"> // unknown (valid)
11
+ * type Invalid = ValidateVersion<"-3"> // never (invalid)
12
+ * ```
13
+ */
3
14
  export type ValidateVersion<T extends String> = T extends `-${infer A}` ? never : T extends `${infer A}-${string}` ? ValidateVersion<A> : T extends `${bigint}` ? unknown : T extends `${bigint}.${infer A}` ? ValidateVersion<A> : never;
15
+ /**
16
+ * Compile-time utility type that validates an extended version string literal.
17
+ *
18
+ * Extended versions have the format `upstream:downstream` or `#flavor:upstream:downstream`.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * type Valid = ValidateExVer<"1.2.3:0"> // valid
23
+ * type Flavored = ValidateExVer<"#bitcoin:1.0:0"> // valid
24
+ * type Bad = ValidateExVer<"1.2-3"> // never (invalid)
25
+ * ```
26
+ */
4
27
  export type ValidateExVer<T extends string> = T extends `#${string}:${infer A}:${infer B}` ? ValidateVersion<A> & ValidateVersion<B> : T extends `${infer A}:${infer B}` ? ValidateVersion<A> & ValidateVersion<B> : never;
28
+ /**
29
+ * Validates a tuple of extended version string literals at compile time.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * type Valid = ValidateExVers<["1.0:0", "2.0:0"]> // valid
34
+ * ```
35
+ */
5
36
  export type ValidateExVers<T> = T extends [] ? unknown[] : T extends [infer A, ...infer B] ? ValidateExVer<A & string> & ValidateExVers<B> : never[];
6
37
  type Anchor = {
7
38
  type: 'Anchor';
@@ -85,55 +116,234 @@ declare class VersionRangeTable {
85
116
  */
86
117
  static minterms(tables: VersionRangeTables): VersionRange;
87
118
  }
119
+ /**
120
+ * Represents a parsed version range expression used to match against {@link Version} or {@link ExtendedVersion} values.
121
+ *
122
+ * Version ranges support standard comparison operators (`=`, `>`, `<`, `>=`, `<=`, `!=`),
123
+ * caret (`^`) and tilde (`~`) ranges, boolean logic (`&&`, `||`, `!`), and flavor matching (`#flavor`).
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * const range = VersionRange.parse(">=1.0.0:0 && <2.0.0:0")
128
+ * const version = ExtendedVersion.parse("1.5.0:0")
129
+ * console.log(range.satisfiedBy(version)) // true
130
+ *
131
+ * // Combine ranges with boolean logic
132
+ * const combined = VersionRange.and(
133
+ * VersionRange.parse(">=1.0:0"),
134
+ * VersionRange.parse("<3.0:0"),
135
+ * )
136
+ *
137
+ * // Match a specific flavor
138
+ * const flavored = VersionRange.parse("#bitcoin")
139
+ * ```
140
+ */
88
141
  export declare class VersionRange {
89
142
  atom: Anchor | And | Or | Not | P.Any | P.None | Flavor;
90
143
  constructor(atom: Anchor | And | Or | Not | P.Any | P.None | Flavor);
91
144
  toStringParens(parent: 'And' | 'Or' | 'Not'): string;
145
+ /** Serializes this version range back to its canonical string representation. */
92
146
  toString(): string;
93
147
  private static parseAtom;
94
148
  private static parseRange;
149
+ /**
150
+ * Parses a version range string into a `VersionRange`.
151
+ *
152
+ * @param range - A version range expression, e.g. `">=1.0.0:0 && <2.0.0:0"`, `"^1.2:0"`, `"*"`
153
+ * @returns The parsed `VersionRange`
154
+ * @throws If the string is not a valid version range expression
155
+ */
95
156
  static parse(range: string): VersionRange;
157
+ /**
158
+ * Creates a version range from a comparison operator and an {@link ExtendedVersion}.
159
+ *
160
+ * @param operator - One of `"="`, `">"`, `"<"`, `">="`, `"<="`, `"!="`, `"^"`, `"~"`
161
+ * @param version - The version to compare against
162
+ */
96
163
  static anchor(operator: P.CmpOp, version: ExtendedVersion): VersionRange;
164
+ /**
165
+ * Creates a version range that matches only versions with the specified flavor.
166
+ *
167
+ * @param flavor - The flavor string to match, or `null` for the default (unflavored) variant
168
+ */
97
169
  static flavor(flavor: string | null): VersionRange;
170
+ /**
171
+ * Parses a legacy "emver" format version range string.
172
+ *
173
+ * @param range - A version range in the legacy emver format
174
+ * @returns The parsed `VersionRange`
175
+ */
98
176
  static parseEmver(range: string): VersionRange;
177
+ /** Returns the intersection of this range with another (logical AND). */
99
178
  and(right: VersionRange): VersionRange;
179
+ /** Returns the union of this range with another (logical OR). */
100
180
  or(right: VersionRange): VersionRange;
181
+ /** Returns the negation of this range (logical NOT). */
101
182
  not(): VersionRange;
183
+ /**
184
+ * Returns the logical AND (intersection) of multiple version ranges.
185
+ * Short-circuits on `none()` and skips `any()`.
186
+ */
102
187
  static and(...xs: Array<VersionRange>): VersionRange;
188
+ /**
189
+ * Returns the logical OR (union) of multiple version ranges.
190
+ * Short-circuits on `any()` and skips `none()`.
191
+ */
103
192
  static or(...xs: Array<VersionRange>): VersionRange;
193
+ /** Returns a version range that matches all versions (wildcard `*`). */
104
194
  static any(): VersionRange;
195
+ /** Returns a version range that matches no versions (`!`). */
105
196
  static none(): VersionRange;
197
+ /**
198
+ * Returns `true` if the given version satisfies this range.
199
+ *
200
+ * @param version - A {@link Version} or {@link ExtendedVersion} to test
201
+ */
106
202
  satisfiedBy(version: Version | ExtendedVersion): boolean;
107
203
  tables(): VersionRangeTables;
204
+ /** Returns `true` if any version exists that could satisfy this range. */
108
205
  satisfiable(): boolean;
206
+ /** Returns `true` if this range and `other` share at least one satisfying version. */
109
207
  intersects(other: VersionRange): boolean;
208
+ /**
209
+ * Returns a canonical (simplified) form of this range using minterm expansion.
210
+ * Useful for normalizing complex boolean expressions into a minimal representation.
211
+ */
110
212
  normalize(): VersionRange;
111
213
  }
214
+ /**
215
+ * Represents a semantic version number with numeric segments and optional prerelease identifiers.
216
+ *
217
+ * Follows semver precedence rules: numeric segments are compared left-to-right,
218
+ * and a version with prerelease identifiers has lower precedence than the same version without.
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * const v = Version.parse("1.2.3")
223
+ * console.log(v.toString()) // "1.2.3"
224
+ * console.log(v.compare(Version.parse("1.3.0"))) // "less"
225
+ *
226
+ * const pre = Version.parse("2.0.0-beta.1")
227
+ * console.log(pre.compare(Version.parse("2.0.0"))) // "less" (prerelease < release)
228
+ * ```
229
+ */
112
230
  export declare class Version {
231
+ /** The numeric version segments (e.g. `[1, 2, 3]` for `"1.2.3"`). */
113
232
  number: number[];
233
+ /** Optional prerelease identifiers (e.g. `["beta", 1]` for `"-beta.1"`). */
114
234
  prerelease: (string | number)[];
115
- constructor(number: number[], prerelease: (string | number)[]);
235
+ constructor(
236
+ /** The numeric version segments (e.g. `[1, 2, 3]` for `"1.2.3"`). */
237
+ number: number[],
238
+ /** Optional prerelease identifiers (e.g. `["beta", 1]` for `"-beta.1"`). */
239
+ prerelease: (string | number)[]);
240
+ /** Serializes this version to its string form (e.g. `"1.2.3"` or `"1.0.0-beta.1"`). */
116
241
  toString(): string;
242
+ /**
243
+ * Compares this version against another using semver precedence rules.
244
+ *
245
+ * @param other - The version to compare against
246
+ * @returns `'greater'`, `'equal'`, or `'less'`
247
+ */
117
248
  compare(other: Version): 'greater' | 'equal' | 'less';
249
+ /**
250
+ * Compares two versions, returning a numeric value suitable for use with `Array.sort()`.
251
+ *
252
+ * @returns `-1` if less, `0` if equal, `1` if greater
253
+ */
118
254
  compareForSort(other: Version): -1 | 0 | 1;
255
+ /**
256
+ * Parses a version string into a `Version` instance.
257
+ *
258
+ * @param version - A semver-compatible string, e.g. `"1.2.3"` or `"1.0.0-beta.1"`
259
+ * @throws If the string is not a valid version
260
+ */
119
261
  static parse(version: string): Version;
262
+ /**
263
+ * Returns `true` if this version satisfies the given {@link VersionRange}.
264
+ * Internally treats this as an unflavored {@link ExtendedVersion} with downstream `0`.
265
+ */
120
266
  satisfies(versionRange: VersionRange): boolean;
121
267
  }
268
+ /**
269
+ * Represents an extended version with an optional flavor, an upstream version, and a downstream version.
270
+ *
271
+ * The format is `#flavor:upstream:downstream` (e.g. `#bitcoin:1.2.3:0`) or `upstream:downstream`
272
+ * for unflavored versions. Flavors allow multiple variants of a package to coexist.
273
+ *
274
+ * - **flavor**: An optional string identifier for the variant (e.g. `"bitcoin"`, `"litecoin"`)
275
+ * - **upstream**: The version of the upstream software being packaged
276
+ * - **downstream**: The version of the StartOS packaging itself
277
+ *
278
+ * Versions with different flavors are incomparable (comparison returns `null`).
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * const v = ExtendedVersion.parse("#bitcoin:1.2.3:0")
283
+ * console.log(v.flavor) // "bitcoin"
284
+ * console.log(v.upstream) // Version { number: [1, 2, 3] }
285
+ * console.log(v.downstream) // Version { number: [0] }
286
+ * console.log(v.toString()) // "#bitcoin:1.2.3:0"
287
+ *
288
+ * const range = VersionRange.parse(">=1.0.0:0")
289
+ * console.log(v.satisfies(range)) // true
290
+ * ```
291
+ */
122
292
  export declare class ExtendedVersion {
293
+ /** The flavor identifier (e.g. `"bitcoin"`), or `null` for unflavored versions. */
123
294
  flavor: string | null;
295
+ /** The upstream software version. */
124
296
  upstream: Version;
297
+ /** The downstream packaging version. */
125
298
  downstream: Version;
126
- constructor(flavor: string | null, upstream: Version, downstream: Version);
299
+ constructor(
300
+ /** The flavor identifier (e.g. `"bitcoin"`), or `null` for unflavored versions. */
301
+ flavor: string | null,
302
+ /** The upstream software version. */
303
+ upstream: Version,
304
+ /** The downstream packaging version. */
305
+ downstream: Version);
306
+ /** Serializes this extended version to its string form (e.g. `"#bitcoin:1.2.3:0"` or `"1.0.0:1"`). */
127
307
  toString(): string;
308
+ /**
309
+ * Compares this extended version against another.
310
+ *
311
+ * @returns `'greater'`, `'equal'`, `'less'`, or `null` if the flavors differ (incomparable)
312
+ */
128
313
  compare(other: ExtendedVersion): 'greater' | 'equal' | 'less' | null;
314
+ /**
315
+ * Lexicographic comparison — compares flavors alphabetically first, then versions.
316
+ * Unlike {@link compare}, this never returns `null`: different flavors are ordered alphabetically.
317
+ */
129
318
  compareLexicographic(other: ExtendedVersion): 'greater' | 'equal' | 'less';
319
+ /**
320
+ * Returns a numeric comparison result suitable for use with `Array.sort()`.
321
+ * Uses lexicographic ordering (flavors sorted alphabetically, then by version).
322
+ */
130
323
  compareForSort(other: ExtendedVersion): 1 | 0 | -1;
324
+ /** Returns `true` if this version is strictly greater than `other`. Returns `false` if flavors differ. */
131
325
  greaterThan(other: ExtendedVersion): boolean;
326
+ /** Returns `true` if this version is greater than or equal to `other`. Returns `false` if flavors differ. */
132
327
  greaterThanOrEqual(other: ExtendedVersion): boolean;
328
+ /** Returns `true` if this version equals `other` (same flavor, upstream, and downstream). */
133
329
  equals(other: ExtendedVersion): boolean;
330
+ /** Returns `true` if this version is strictly less than `other`. Returns `false` if flavors differ. */
134
331
  lessThan(other: ExtendedVersion): boolean;
332
+ /** Returns `true` if this version is less than or equal to `other`. Returns `false` if flavors differ. */
135
333
  lessThanOrEqual(other: ExtendedVersion): boolean;
334
+ /**
335
+ * Parses an extended version string into an `ExtendedVersion`.
336
+ *
337
+ * @param extendedVersion - A string like `"1.2.3:0"` or `"#bitcoin:1.0.0:0"`
338
+ * @throws If the string is not a valid extended version
339
+ */
136
340
  static parse(extendedVersion: string): ExtendedVersion;
341
+ /**
342
+ * Parses a legacy "emver" format extended version string.
343
+ *
344
+ * @param extendedVersion - A version string in the legacy emver format
345
+ * @throws If the string is not a valid emver version (error message includes the input string)
346
+ */
137
347
  static parseEmver(extendedVersion: string): ExtendedVersion;
138
348
  /**
139
349
  * Returns an ExtendedVersion with the Upstream major version version incremented by 1
@@ -153,6 +363,27 @@ export declare class ExtendedVersion {
153
363
  */
154
364
  satisfies(versionRange: VersionRange): boolean;
155
365
  }
366
+ /**
367
+ * Compile-time type-checking helper that validates an extended version string literal.
368
+ * If the string is invalid, TypeScript will report a type error at the call site.
369
+ *
370
+ * @example
371
+ * ```ts
372
+ * testTypeExVer("1.2.3:0") // compiles
373
+ * testTypeExVer("#bitcoin:1.0:0") // compiles
374
+ * testTypeExVer("invalid") // type error
375
+ * ```
376
+ */
156
377
  export declare const testTypeExVer: <T extends string>(t: T & ValidateExVer<T>) => T & ValidateExVer<T>;
378
+ /**
379
+ * Compile-time type-checking helper that validates a version string literal.
380
+ * If the string is invalid, TypeScript will report a type error at the call site.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * testTypeVersion("1.2.3") // compiles
385
+ * testTypeVersion("-3") // type error
386
+ * ```
387
+ */
157
388
  export declare const testTypeVersion: <T extends string>(t: T & ValidateVersion<T>) => T & ValidateVersion<T>;
158
389
  export {};
@@ -358,6 +358,28 @@ class VersionRangeTable {
358
358
  return VersionRange.or(...sum_terms);
359
359
  }
360
360
  }
361
+ /**
362
+ * Represents a parsed version range expression used to match against {@link Version} or {@link ExtendedVersion} values.
363
+ *
364
+ * Version ranges support standard comparison operators (`=`, `>`, `<`, `>=`, `<=`, `!=`),
365
+ * caret (`^`) and tilde (`~`) ranges, boolean logic (`&&`, `||`, `!`), and flavor matching (`#flavor`).
366
+ *
367
+ * @example
368
+ * ```ts
369
+ * const range = VersionRange.parse(">=1.0.0:0 && <2.0.0:0")
370
+ * const version = ExtendedVersion.parse("1.5.0:0")
371
+ * console.log(range.satisfiedBy(version)) // true
372
+ *
373
+ * // Combine ranges with boolean logic
374
+ * const combined = VersionRange.and(
375
+ * VersionRange.parse(">=1.0:0"),
376
+ * VersionRange.parse("<3.0:0"),
377
+ * )
378
+ *
379
+ * // Match a specific flavor
380
+ * const flavored = VersionRange.parse("#bitcoin")
381
+ * ```
382
+ */
361
383
  class VersionRange {
362
384
  constructor(atom) {
363
385
  this.atom = atom;
@@ -386,6 +408,7 @@ class VersionRange {
386
408
  return this.toString();
387
409
  }
388
410
  }
411
+ /** Serializes this version range back to its canonical string representation. */
389
412
  toString() {
390
413
  switch (this.atom.type) {
391
414
  case 'Anchor':
@@ -448,27 +471,58 @@ class VersionRange {
448
471
  }
449
472
  return result;
450
473
  }
474
+ /**
475
+ * Parses a version range string into a `VersionRange`.
476
+ *
477
+ * @param range - A version range expression, e.g. `">=1.0.0:0 && <2.0.0:0"`, `"^1.2:0"`, `"*"`
478
+ * @returns The parsed `VersionRange`
479
+ * @throws If the string is not a valid version range expression
480
+ */
451
481
  static parse(range) {
452
482
  return VersionRange.parseRange(P.parse(range, { startRule: 'VersionRange' }));
453
483
  }
484
+ /**
485
+ * Creates a version range from a comparison operator and an {@link ExtendedVersion}.
486
+ *
487
+ * @param operator - One of `"="`, `">"`, `"<"`, `">="`, `"<="`, `"!="`, `"^"`, `"~"`
488
+ * @param version - The version to compare against
489
+ */
454
490
  static anchor(operator, version) {
455
491
  return new VersionRange({ type: 'Anchor', operator, version });
456
492
  }
493
+ /**
494
+ * Creates a version range that matches only versions with the specified flavor.
495
+ *
496
+ * @param flavor - The flavor string to match, or `null` for the default (unflavored) variant
497
+ */
457
498
  static flavor(flavor) {
458
499
  return new VersionRange({ type: 'Flavor', flavor });
459
500
  }
501
+ /**
502
+ * Parses a legacy "emver" format version range string.
503
+ *
504
+ * @param range - A version range in the legacy emver format
505
+ * @returns The parsed `VersionRange`
506
+ */
460
507
  static parseEmver(range) {
461
508
  return VersionRange.parseRange(P.parse(range, { startRule: 'EmverVersionRange' }));
462
509
  }
510
+ /** Returns the intersection of this range with another (logical AND). */
463
511
  and(right) {
464
512
  return new VersionRange({ type: 'And', left: this, right });
465
513
  }
514
+ /** Returns the union of this range with another (logical OR). */
466
515
  or(right) {
467
516
  return new VersionRange({ type: 'Or', left: this, right });
468
517
  }
518
+ /** Returns the negation of this range (logical NOT). */
469
519
  not() {
470
520
  return new VersionRange({ type: 'Not', value: this });
471
521
  }
522
+ /**
523
+ * Returns the logical AND (intersection) of multiple version ranges.
524
+ * Short-circuits on `none()` and skips `any()`.
525
+ */
472
526
  static and(...xs) {
473
527
  let y = VersionRange.any();
474
528
  for (let x of xs) {
@@ -487,6 +541,10 @@ class VersionRange {
487
541
  }
488
542
  return y;
489
543
  }
544
+ /**
545
+ * Returns the logical OR (union) of multiple version ranges.
546
+ * Short-circuits on `any()` and skips `none()`.
547
+ */
490
548
  static or(...xs) {
491
549
  let y = VersionRange.none();
492
550
  for (let x of xs) {
@@ -505,12 +563,19 @@ class VersionRange {
505
563
  }
506
564
  return y;
507
565
  }
566
+ /** Returns a version range that matches all versions (wildcard `*`). */
508
567
  static any() {
509
568
  return new VersionRange({ type: 'Any' });
510
569
  }
570
+ /** Returns a version range that matches no versions (`!`). */
511
571
  static none() {
512
572
  return new VersionRange({ type: 'None' });
513
573
  }
574
+ /**
575
+ * Returns `true` if the given version satisfies this range.
576
+ *
577
+ * @param version - A {@link Version} or {@link ExtendedVersion} to test
578
+ */
514
579
  satisfiedBy(version) {
515
580
  return version.satisfies(this);
516
581
  }
@@ -554,25 +619,58 @@ class VersionRange {
554
619
  return false;
555
620
  }
556
621
  }
622
+ /** Returns `true` if any version exists that could satisfy this range. */
557
623
  satisfiable() {
558
624
  return VersionRangeTable.collapse(this.tables()) !== false;
559
625
  }
626
+ /** Returns `true` if this range and `other` share at least one satisfying version. */
560
627
  intersects(other) {
561
628
  return VersionRange.and(this, other).satisfiable();
562
629
  }
630
+ /**
631
+ * Returns a canonical (simplified) form of this range using minterm expansion.
632
+ * Useful for normalizing complex boolean expressions into a minimal representation.
633
+ */
563
634
  normalize() {
564
635
  return VersionRangeTable.minterms(this.tables());
565
636
  }
566
637
  }
567
638
  exports.VersionRange = VersionRange;
639
+ /**
640
+ * Represents a semantic version number with numeric segments and optional prerelease identifiers.
641
+ *
642
+ * Follows semver precedence rules: numeric segments are compared left-to-right,
643
+ * and a version with prerelease identifiers has lower precedence than the same version without.
644
+ *
645
+ * @example
646
+ * ```ts
647
+ * const v = Version.parse("1.2.3")
648
+ * console.log(v.toString()) // "1.2.3"
649
+ * console.log(v.compare(Version.parse("1.3.0"))) // "less"
650
+ *
651
+ * const pre = Version.parse("2.0.0-beta.1")
652
+ * console.log(pre.compare(Version.parse("2.0.0"))) // "less" (prerelease < release)
653
+ * ```
654
+ */
568
655
  class Version {
569
- constructor(number, prerelease) {
656
+ constructor(
657
+ /** The numeric version segments (e.g. `[1, 2, 3]` for `"1.2.3"`). */
658
+ number,
659
+ /** Optional prerelease identifiers (e.g. `["beta", 1]` for `"-beta.1"`). */
660
+ prerelease) {
570
661
  this.number = number;
571
662
  this.prerelease = prerelease;
572
663
  }
664
+ /** Serializes this version to its string form (e.g. `"1.2.3"` or `"1.0.0-beta.1"`). */
573
665
  toString() {
574
666
  return `${this.number.join('.')}${this.prerelease.length > 0 ? `-${this.prerelease.join('.')}` : ''}`;
575
667
  }
668
+ /**
669
+ * Compares this version against another using semver precedence rules.
670
+ *
671
+ * @param other - The version to compare against
672
+ * @returns `'greater'`, `'equal'`, or `'less'`
673
+ */
576
674
  compare(other) {
577
675
  const numLen = Math.max(this.number.length, other.number.length);
578
676
  for (let i = 0; i < numLen; i++) {
@@ -616,6 +714,11 @@ class Version {
616
714
  }
617
715
  return 'equal';
618
716
  }
717
+ /**
718
+ * Compares two versions, returning a numeric value suitable for use with `Array.sort()`.
719
+ *
720
+ * @returns `-1` if less, `0` if equal, `1` if greater
721
+ */
619
722
  compareForSort(other) {
620
723
  switch (this.compare(other)) {
621
724
  case 'greater':
@@ -626,25 +729,70 @@ class Version {
626
729
  return -1;
627
730
  }
628
731
  }
732
+ /**
733
+ * Parses a version string into a `Version` instance.
734
+ *
735
+ * @param version - A semver-compatible string, e.g. `"1.2.3"` or `"1.0.0-beta.1"`
736
+ * @throws If the string is not a valid version
737
+ */
629
738
  static parse(version) {
630
739
  const parsed = P.parse(version, { startRule: 'Version' });
631
740
  return new Version(parsed.number, parsed.prerelease);
632
741
  }
742
+ /**
743
+ * Returns `true` if this version satisfies the given {@link VersionRange}.
744
+ * Internally treats this as an unflavored {@link ExtendedVersion} with downstream `0`.
745
+ */
633
746
  satisfies(versionRange) {
634
747
  return new ExtendedVersion(null, this, new Version([0], [])).satisfies(versionRange);
635
748
  }
636
749
  }
637
750
  exports.Version = Version;
638
- // #flavor:0.1.2-beta.1:0
751
+ /**
752
+ * Represents an extended version with an optional flavor, an upstream version, and a downstream version.
753
+ *
754
+ * The format is `#flavor:upstream:downstream` (e.g. `#bitcoin:1.2.3:0`) or `upstream:downstream`
755
+ * for unflavored versions. Flavors allow multiple variants of a package to coexist.
756
+ *
757
+ * - **flavor**: An optional string identifier for the variant (e.g. `"bitcoin"`, `"litecoin"`)
758
+ * - **upstream**: The version of the upstream software being packaged
759
+ * - **downstream**: The version of the StartOS packaging itself
760
+ *
761
+ * Versions with different flavors are incomparable (comparison returns `null`).
762
+ *
763
+ * @example
764
+ * ```ts
765
+ * const v = ExtendedVersion.parse("#bitcoin:1.2.3:0")
766
+ * console.log(v.flavor) // "bitcoin"
767
+ * console.log(v.upstream) // Version { number: [1, 2, 3] }
768
+ * console.log(v.downstream) // Version { number: [0] }
769
+ * console.log(v.toString()) // "#bitcoin:1.2.3:0"
770
+ *
771
+ * const range = VersionRange.parse(">=1.0.0:0")
772
+ * console.log(v.satisfies(range)) // true
773
+ * ```
774
+ */
639
775
  class ExtendedVersion {
640
- constructor(flavor, upstream, downstream) {
776
+ constructor(
777
+ /** The flavor identifier (e.g. `"bitcoin"`), or `null` for unflavored versions. */
778
+ flavor,
779
+ /** The upstream software version. */
780
+ upstream,
781
+ /** The downstream packaging version. */
782
+ downstream) {
641
783
  this.flavor = flavor;
642
784
  this.upstream = upstream;
643
785
  this.downstream = downstream;
644
786
  }
787
+ /** Serializes this extended version to its string form (e.g. `"#bitcoin:1.2.3:0"` or `"1.0.0:1"`). */
645
788
  toString() {
646
789
  return `${this.flavor ? `#${this.flavor}:` : ''}${this.upstream.toString()}:${this.downstream.toString()}`;
647
790
  }
791
+ /**
792
+ * Compares this extended version against another.
793
+ *
794
+ * @returns `'greater'`, `'equal'`, `'less'`, or `null` if the flavors differ (incomparable)
795
+ */
648
796
  compare(other) {
649
797
  if (this.flavor !== other.flavor) {
650
798
  return null;
@@ -655,6 +803,10 @@ class ExtendedVersion {
655
803
  }
656
804
  return this.downstream.compare(other.downstream);
657
805
  }
806
+ /**
807
+ * Lexicographic comparison — compares flavors alphabetically first, then versions.
808
+ * Unlike {@link compare}, this never returns `null`: different flavors are ordered alphabetically.
809
+ */
658
810
  compareLexicographic(other) {
659
811
  if ((this.flavor || '') > (other.flavor || '')) {
660
812
  return 'greater';
@@ -666,6 +818,10 @@ class ExtendedVersion {
666
818
  return this.compare(other);
667
819
  }
668
820
  }
821
+ /**
822
+ * Returns a numeric comparison result suitable for use with `Array.sort()`.
823
+ * Uses lexicographic ordering (flavors sorted alphabetically, then by version).
824
+ */
669
825
  compareForSort(other) {
670
826
  switch (this.compareLexicographic(other)) {
671
827
  case 'greater':
@@ -676,25 +832,42 @@ class ExtendedVersion {
676
832
  return -1;
677
833
  }
678
834
  }
835
+ /** Returns `true` if this version is strictly greater than `other`. Returns `false` if flavors differ. */
679
836
  greaterThan(other) {
680
837
  return this.compare(other) === 'greater';
681
838
  }
839
+ /** Returns `true` if this version is greater than or equal to `other`. Returns `false` if flavors differ. */
682
840
  greaterThanOrEqual(other) {
683
841
  return ['greater', 'equal'].includes(this.compare(other));
684
842
  }
843
+ /** Returns `true` if this version equals `other` (same flavor, upstream, and downstream). */
685
844
  equals(other) {
686
845
  return this.compare(other) === 'equal';
687
846
  }
847
+ /** Returns `true` if this version is strictly less than `other`. Returns `false` if flavors differ. */
688
848
  lessThan(other) {
689
849
  return this.compare(other) === 'less';
690
850
  }
851
+ /** Returns `true` if this version is less than or equal to `other`. Returns `false` if flavors differ. */
691
852
  lessThanOrEqual(other) {
692
853
  return ['less', 'equal'].includes(this.compare(other));
693
854
  }
855
+ /**
856
+ * Parses an extended version string into an `ExtendedVersion`.
857
+ *
858
+ * @param extendedVersion - A string like `"1.2.3:0"` or `"#bitcoin:1.0.0:0"`
859
+ * @throws If the string is not a valid extended version
860
+ */
694
861
  static parse(extendedVersion) {
695
862
  const parsed = P.parse(extendedVersion, { startRule: 'ExtendedVersion' });
696
863
  return new ExtendedVersion(parsed.flavor || null, new Version(parsed.upstream.number, parsed.upstream.prerelease), new Version(parsed.downstream.number, parsed.downstream.prerelease));
697
864
  }
865
+ /**
866
+ * Parses a legacy "emver" format extended version string.
867
+ *
868
+ * @param extendedVersion - A version string in the legacy emver format
869
+ * @throws If the string is not a valid emver version (error message includes the input string)
870
+ */
698
871
  static parseEmver(extendedVersion) {
699
872
  try {
700
873
  const parsed = P.parse(extendedVersion, { startRule: 'Emver' });
@@ -806,8 +979,29 @@ class ExtendedVersion {
806
979
  }
807
980
  }
808
981
  exports.ExtendedVersion = ExtendedVersion;
982
+ /**
983
+ * Compile-time type-checking helper that validates an extended version string literal.
984
+ * If the string is invalid, TypeScript will report a type error at the call site.
985
+ *
986
+ * @example
987
+ * ```ts
988
+ * testTypeExVer("1.2.3:0") // compiles
989
+ * testTypeExVer("#bitcoin:1.0:0") // compiles
990
+ * testTypeExVer("invalid") // type error
991
+ * ```
992
+ */
809
993
  const testTypeExVer = (t) => t;
810
994
  exports.testTypeExVer = testTypeExVer;
995
+ /**
996
+ * Compile-time type-checking helper that validates a version string literal.
997
+ * If the string is invalid, TypeScript will report a type error at the call site.
998
+ *
999
+ * @example
1000
+ * ```ts
1001
+ * testTypeVersion("1.2.3") // compiles
1002
+ * testTypeVersion("-3") // type error
1003
+ * ```
1004
+ */
811
1005
  const testTypeVersion = (t) => t;
812
1006
  exports.testTypeVersion = testTypeVersion;
813
1007
  function tests() {