@fgv/ts-extras 5.0.0-24 → 5.0.0-25

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.
@@ -0,0 +1,602 @@
1
+ import { Conversion } from '@fgv/ts-utils';
2
+ import { Converter } from '@fgv/ts-utils';
3
+ import { FileTree } from '@fgv/ts-utils';
4
+ import { Hash as Hash_2 } from '@fgv/ts-utils';
5
+ import { Result } from '@fgv/ts-utils';
6
+ import { Validator } from '@fgv/ts-utils';
7
+
8
+ declare namespace Converters {
9
+ export {
10
+ templateString,
11
+ extendedArrayOf,
12
+ rangeTypeOf,
13
+ rangeOf,
14
+ isoDate
15
+ }
16
+ }
17
+ export { Converters }
18
+
19
+ declare namespace Csv {
20
+ export {
21
+ readCsvFileSync,
22
+ CsvOptions
23
+ }
24
+ }
25
+ export { Csv }
26
+
27
+ /**
28
+ * Options for {@link Csv.readCsvFileSync | readCsvFileSync}
29
+ * @beta
30
+ */
31
+ declare interface CsvOptions {
32
+ delimiter?: string;
33
+ }
34
+
35
+ /**
36
+ * Default {@link Experimental.RangeOfFormats | formats} to use for both
37
+ * open-ended and complete {@link Experimental.RangeOf | RangeOf<T>}.
38
+ * @public
39
+ */
40
+ declare const DEFAULT_RANGEOF_FORMATS: RangeOfFormats;
41
+
42
+ declare namespace Experimental {
43
+ export {
44
+ ExtendedArray,
45
+ formatList,
46
+ FormatTargets,
47
+ Formattable,
48
+ FormattableBase,
49
+ Formatter,
50
+ FormattersByExtendedTarget,
51
+ FormattersByTarget,
52
+ RangeOfProperties,
53
+ RangeOfFormats,
54
+ DEFAULT_RANGEOF_FORMATS,
55
+ RangeOf
56
+ }
57
+ }
58
+ export { Experimental }
59
+
60
+ /**
61
+ * An experimental array template which extend built-in `Array` to include a handful
62
+ * of predicates which return `Result<T>`.
63
+ * @beta
64
+ */
65
+ declare class ExtendedArray<T> extends Array<T> {
66
+ readonly itemDescription: string;
67
+ /**
68
+ * Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.
69
+ * @param itemDescription - Brief description of the type of each item in this array.
70
+ * @param items - The initial contents of the array.
71
+ */
72
+ constructor(itemDescription: string, ...items: T[]);
73
+ /**
74
+ * Type guard to determine if some arbitrary array is an
75
+ * {@link Experimental.ExtendedArray}
76
+ * @param a - The `Array` to be tested.
77
+ * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},
78
+ * `false` otherwise.
79
+ */
80
+ static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T>;
81
+ /**
82
+ * Determines if this array contains exactly one element which matches
83
+ * a supplied predicate.
84
+ * @param predicate - The predicate function to be applied.
85
+ * @returns Returns `Success<T>` with the single matching
86
+ * result if exactly one item matches `predicate`. Returns `Failure<T>`
87
+ * with an error message if there are no matches or more than one match.
88
+ */
89
+ single(predicate?: (item: T) => boolean): Result<T>;
90
+ /**
91
+ * Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an
92
+ * error message if the array is empty.
93
+ * @param failMessage - Optional message to be displayed in the event of failure.
94
+ * @returns Returns `Success<T>` with the value of the first element
95
+ * in the array, or `Failure<T>` with an error message if the array is empty.
96
+ */
97
+ first(failMessage?: string): Result<T>;
98
+ /**
99
+ * Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.
100
+ * Fails with an error message if the array is empty.
101
+ * @param failMessage - Optional message to be displayed in the event of failure.
102
+ * @returns Returns `Success<T>` with a new (non-extended) `Array`
103
+ * containing the elements of this array, or `Failure<T>` with an error message
104
+ * if the array is empty.
105
+ */
106
+ atLeastOne(failMessage?: string): Result<T[]>;
107
+ /**
108
+ * Gets a new (non-extended) `Array` containing all of the elements from this
109
+ * {@link Experimental.ExtendedArray | ExtendedArray}.
110
+ * @returns A new (non-extended) `Array<T>`.
111
+ */
112
+ all(): T[];
113
+ }
114
+
115
+ /**
116
+ * A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.
117
+ * @remarks
118
+ * If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot
119
+ * be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.
120
+ * @param converter - `Converter` used to convert each item in the array
121
+ * @param ignoreErrors - Specifies treatment of unconvertible elements
122
+ * @beta
123
+ */
124
+ declare function extendedArrayOf<T, TC = undefined>(label: string, converter: Converter<T, TC>, onError?: Conversion.OnError): Converter<ExtendedArray<T>, TC>;
125
+
126
+ /**
127
+ * Formats a list of items using the supplied template and formatter, one result
128
+ * per output line.
129
+ * @param format - A mustache template used to format each item.
130
+ * @param items - The items to be formatted.
131
+ * @param itemFormatter - The {@link Experimental.Formatter | Formatter<T>} used to format each item.
132
+ * @returns The resulting string.
133
+ * @beta
134
+ */
135
+ declare function formatList<T>(format: string, items: T[], itemFormatter: Formatter<T>): Result<string>;
136
+
137
+ /**
138
+ * Interface for an object that can be formatted.
139
+ * @beta
140
+ */
141
+ declare interface Formattable {
142
+ /**
143
+ * Formats an object using the supplied mustache template.
144
+ * @param format - A mustache template used to format the object.
145
+ * @returns `Success<string>` with the resulting string, or `Failure<string>`
146
+ * with an error message if an error occurs.
147
+ */
148
+ format(format: string): Result<string>;
149
+ }
150
+
151
+ /**
152
+ * Base class which adds common formatting.
153
+ * @beta
154
+ */
155
+ declare class FormattableBase {
156
+ /**
157
+ * Helper enables derived classes to add named details to a formatted presentation.
158
+ * @param details - An array of detail description strings.
159
+ * @param label - Label to use for the new detail.
160
+ * @param value - Value to use for the new detail.
161
+ * @internal
162
+ */
163
+ protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void;
164
+ /**
165
+ * {@inheritdoc Experimental.Formattable.format}
166
+ */
167
+ format(template: string): Result<string>;
168
+ }
169
+
170
+ /**
171
+ * Destination format for some formatted string.
172
+ * @beta
173
+ */
174
+ declare type FormatTargets = 'text' | 'markdown' | 'embed';
175
+
176
+ /**
177
+ * Type definition for a formatting function, which takes a `string` and an
178
+ * item and returns `Result<string>`.
179
+ * @beta
180
+ */
181
+ declare type Formatter<T> = (format: string, item: T) => Result<string>;
182
+
183
+ /**
184
+ * A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable
185
+ * different format methods per output target.
186
+ * @beta
187
+ */
188
+ declare type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;
189
+
190
+ /**
191
+ * A collection of {@link Experimental.Formatter | formatters} indexed by the
192
+ * {@link Experimental.FormatTargets | default supported target formats}.
193
+ * @beta
194
+ */
195
+ declare type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;
196
+
197
+ declare namespace Hash {
198
+ export {
199
+ Md5Normalizer
200
+ }
201
+ }
202
+ export { Hash }
203
+
204
+ /**
205
+ * A `Converter` which converts an iso formatted string, a number or a `Date` object to
206
+ * a `Date` object.
207
+ * @public
208
+ */
209
+ declare const isoDate: Converter<Date, unknown>;
210
+
211
+ /**
212
+ * @public
213
+ */
214
+ declare type JarFieldPicker<T extends JarRecord = JarRecord> = (record: T) => (keyof T)[];
215
+
216
+ /**
217
+ * Represents a single record in a JAR file
218
+ * @public
219
+ */
220
+ declare type JarRecord = Record<string, string | string[]>;
221
+
222
+ /**
223
+ * Options for a JAR record parser.
224
+ * @public
225
+ */
226
+ declare interface JarRecordParserOptions {
227
+ readonly arrayFields?: string[] | JarFieldPicker;
228
+ readonly fixedContinuationSize?: number;
229
+ }
230
+
231
+ /**
232
+ * A hashing normalizer which computes object
233
+ * hash using the MD5 algorithm.
234
+ * @public
235
+ */
236
+ declare class Md5Normalizer extends Hash_2.HashingNormalizer {
237
+ constructor();
238
+ static md5Hash(parts: string[]): string;
239
+ }
240
+
241
+ /**
242
+ * Reads a record-jar from an array of strings, each of which represents one
243
+ * line in the source file.
244
+ * @param lines - the array of strings to be parsed
245
+ * @param options - Optional parser configuration
246
+ * @returns a corresponding array of `Record<string, string>`
247
+ * @public
248
+ */
249
+ declare function parseRecordJarLines(lines: string[], options?: JarRecordParserOptions): Result<JarRecord[]>;
250
+
251
+ /**
252
+ * Simple implementation of a possibly open-ended range of some comparable
253
+ * type `<T>` with test and formatting.
254
+ * @public
255
+ */
256
+ declare class RangeOf<T> implements RangeOfProperties<T> {
257
+ /**
258
+ * Minimum extent of the range.
259
+ */
260
+ readonly min?: T;
261
+ /**
262
+ * Maximum extent of the range.
263
+ */
264
+ readonly max?: T;
265
+ /**
266
+ * Creates a new {@link Experimental.RangeOf | RangeOf<T>}.
267
+ * @param min - Optional minimum extent of the range.
268
+ * @param max - Optional maximum extent of the range.
269
+ */
270
+ constructor(min?: T, max?: T);
271
+ /**
272
+ * Static constructor for a {@link Experimental.RangeOf | RangeOf<T>}.
273
+ * @param init - {@link Experimental.RangeOfProperties | Range initializer}.
274
+ * @returns A new {@link Experimental.RangeOf | RangeOf<T>}.
275
+ */
276
+ static createRange<T>(init?: RangeOfProperties<T>): Result<RangeOf<T>>;
277
+ /**
278
+ * Gets a formatted description of a {@link Experimental.RangeOfProperties | RangeOfProperties<T>} given an
279
+ * optional set of formats and 'empty' value to use.
280
+ * @param range - The {@link Experimental.RangeOfProperties | RangeOfProperties<T>} to be formatted.
281
+ * @param formats - Optional {@link Experimental.RangeOfFormats | formats} to use. Default is
282
+ * {@link Experimental.DEFAULT_RANGEOF_FORMATS | DEFAULT_RANGEOF_FORMATS}.
283
+ * @param emptyValue - Value which represents unbounded minimum or maximum for this range. Default is `undefined`.
284
+ * @returns A string representation of the range.
285
+ */
286
+ static propertiesToString<T>(range: RangeOfProperties<T>, formats?: RangeOfFormats, emptyValue?: T): string | undefined;
287
+ /**
288
+ * Default comparison uses javascript built-in comparison.
289
+ * @param t1 - First value to be compared.
290
+ * @param t2 - Second value to be compared.
291
+ * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger
292
+ * and `'equal'` if `t1` and `t2` are equal.
293
+ * @internal
294
+ */
295
+ protected static _defaultCompare<T>(t1: T, t2: T): 'less' | 'equal' | 'greater';
296
+ /**
297
+ * Checks if a supplied value is within this range.
298
+ * @param t - The value to be tested.
299
+ * @returns `'included'` if `t` falls within the range, `'less'` if `t` falls
300
+ * below the minimum extent of the range and `'greater'` if `t` is above the
301
+ * maximum extent.
302
+ */
303
+ check(t: T): 'less' | 'included' | 'greater';
304
+ /**
305
+ * Determines if a supplied value is within this range.
306
+ * @param t - The value to be tested.
307
+ * @returns Returns `true` if `t` falls within the range, `false` otherwise.
308
+ */
309
+ includes(t: T): boolean;
310
+ /**
311
+ * Finds the transition value that would bring a supplied value `t` into
312
+ * range.
313
+ * @param t - The value to be tested.
314
+ * @returns The minimum extent of the range if `t` is below the range or
315
+ * the maximum extent of the range if `t` is above the range. Returns
316
+ * `undefined` if `t` already falls within the range.
317
+ */
318
+ findTransition(t: T): T | undefined;
319
+ /**
320
+ * Formats the minimum and maximum values of this range.
321
+ * @param format - A format function used to format the values.
322
+ * @returns A {@link Experimental.RangeOfProperties | RangeOfProperties<string>} containing the
323
+ * formatted representation of the {@link Experimental.RangeOf.min | minimum} and
324
+ * {@link Experimental.RangeOf.max | maximum}
325
+ * extent of the range, or `undefined` for an extent that is not present.
326
+ */
327
+ toFormattedProperties(format: (value: T) => string | undefined): RangeOfProperties<string>;
328
+ /**
329
+ * Formats this range using the supplied format function.
330
+ * @param format - Format function used to format minimum and maximum extent values.
331
+ * @param formats - The {@link Experimental.RangeOfFormats | format strings} used to format the range
332
+ * (default {@link Experimental.DEFAULT_RANGEOF_FORMATS}).
333
+ * @returns Returns a formatted representation of this range.
334
+ */
335
+ format(format: (value: T) => string | undefined, formats?: RangeOfFormats): string | undefined;
336
+ /**
337
+ * Inner compare method can be overridden by a derived class.
338
+ * @param t1 - First value to compare.
339
+ * @param t2 - Second value to compare.
340
+ * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger
341
+ * and `'equal'` if `t1` and `t2` are equal.
342
+ * @internal
343
+ */
344
+ protected _compare(t1: T, t2: T): 'less' | 'equal' | 'greater';
345
+ }
346
+
347
+ /**
348
+ * A helper wrapper to construct a `Converter` which converts to {@link Experimental.RangeOf | RangeOf<T>}
349
+ * where `<T>` is some comparable type.
350
+ * @param converter - `Converter` used to convert `min` and `max` extent of the range.
351
+ * @public
352
+ */
353
+ declare function rangeOf<T, TC = unknown>(converter: Converter<T, TC>): Converter<RangeOf<T>, TC>;
354
+
355
+ /**
356
+ * Format strings (in mustache format) to
357
+ * use for both open-ended and complete
358
+ * {@link Experimental.RangeOf | RangeOf<T>}.
359
+ * @public
360
+ */
361
+ declare interface RangeOfFormats {
362
+ minOnly: string;
363
+ maxOnly: string;
364
+ minMax: string;
365
+ }
366
+
367
+ /**
368
+ * Represents a generic range of some comparable type `<T>`.
369
+ * @public
370
+ */
371
+ declare interface RangeOfProperties<T> {
372
+ readonly min?: T;
373
+ readonly max?: T;
374
+ }
375
+
376
+ /**
377
+ * A helper wrapper to construct a `Converter` which converts to an arbitrary strongly-typed
378
+ * range of some comparable type.
379
+ * @param converter - `Converter` used to convert `min` and `max` extent of the range.
380
+ * @param constructor - Static constructor to instantiate the object.
381
+ * @public
382
+ */
383
+ declare function rangeTypeOf<T, RT extends RangeOf<T>, TC = unknown>(converter: Converter<T, TC>, constructor: (init: RangeOfProperties<T>) => Result<RT>): Converter<RT, TC>;
384
+
385
+ /**
386
+ * Reads a CSV file from a supplied path.
387
+ * @param srcPath - Source path from which the file is read.
388
+ * @param options - optional parameters to control the processing
389
+ * @returns The contents of the file.
390
+ * @beta
391
+ */
392
+ declare function readCsvFileSync(srcPath: string, options?: CsvOptions): Result<unknown>;
393
+
394
+ /**
395
+ * Reads a record-jar file from a supplied path.
396
+ * @param srcPath - Source path from which the file is read.
397
+ * @param options - Optional parser configuration
398
+ * @returns The contents of the file as an array of `Record<string, string>`
399
+ * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01
400
+ * @public
401
+ */
402
+ declare function readRecordJarFileSync(srcPath: string, options?: JarRecordParserOptions): Result<JarRecord[]>;
403
+
404
+ declare namespace RecordJar {
405
+ export {
406
+ parseRecordJarLines,
407
+ readRecordJarFileSync,
408
+ JarRecord,
409
+ JarFieldPicker,
410
+ JarRecordParserOptions
411
+ }
412
+ }
413
+ export { RecordJar }
414
+
415
+ /**
416
+ * Helper function to create a `StringConverter` which converts
417
+ * `unknown` to `string`, applying template conversions supplied at construction time or at
418
+ * runtime as context.
419
+ * @remarks
420
+ * Template conversions are applied using `mustache` syntax.
421
+ * @param defaultContext - Optional default context to use for template values.
422
+ * @returns A new `Converter` returning `string`.
423
+ * @public
424
+ */
425
+ declare function templateString(defaultContext?: unknown): Conversion.StringConverter<string, unknown>;
426
+
427
+ /**
428
+ * Implementation of `IFileTreeDirectoryItem` for directories in a ZIP archive.
429
+ * @public
430
+ */
431
+ declare class ZipDirectoryItem implements FileTree.IFileTreeDirectoryItem {
432
+ /**
433
+ * Indicates that this `FileTree.FileTreeItem` is a directory.
434
+ */
435
+ readonly type: 'directory';
436
+ /**
437
+ * The absolute path of the directory within the ZIP archive.
438
+ */
439
+ readonly absolutePath: string;
440
+ /**
441
+ * The name of the directory
442
+ */
443
+ readonly name: string;
444
+ /**
445
+ * The ZIP file tree accessors that created this item.
446
+ */
447
+ private readonly _accessors;
448
+ /**
449
+ * Constructor for ZipDirectoryItem.
450
+ * @param directoryPath - The path of the directory within the ZIP.
451
+ * @param accessors - The ZIP file tree accessors.
452
+ */
453
+ constructor(directoryPath: string, accessors: ZipFileTreeAccessors);
454
+ /**
455
+ * Gets the children of the directory.
456
+ */
457
+ getChildren(): Result<ReadonlyArray<FileTree.FileTreeItem>>;
458
+ }
459
+
460
+ /**
461
+ * Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.
462
+ * @public
463
+ */
464
+ declare class ZipFileItem implements FileTree.IFileTreeFileItem {
465
+ /**
466
+ * Indicates that this `FileTree.FileTreeItem` is a file.
467
+ */
468
+ readonly type: 'file';
469
+ /**
470
+ * The absolute path of the file within the ZIP archive.
471
+ */
472
+ readonly absolutePath: string;
473
+ /**
474
+ * The name of the file
475
+ */
476
+ readonly name: string;
477
+ /**
478
+ * The base name of the file (without extension)
479
+ */
480
+ readonly baseName: string;
481
+ /**
482
+ * The extension of the file
483
+ */
484
+ readonly extension: string;
485
+ /**
486
+ * The pre-loaded contents of the file.
487
+ */
488
+ private readonly _contents;
489
+ /**
490
+ * The ZIP file tree accessors that created this item.
491
+ */
492
+ private readonly _accessors;
493
+ /**
494
+ * Constructor for ZipFileItem.
495
+ * @param zipFilePath - The path of the file within the ZIP.
496
+ * @param contents - The pre-loaded contents of the file.
497
+ * @param accessors - The ZIP file tree accessors.
498
+ */
499
+ constructor(zipFilePath: string, contents: string, accessors: ZipFileTreeAccessors);
500
+ /**
501
+ * Gets the contents of the file as parsed JSON.
502
+ */
503
+ getContents(): Result<unknown>;
504
+ getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;
505
+ /**
506
+ * Gets the raw contents of the file as a string.
507
+ */
508
+ getRawContents(): Result<string>;
509
+ }
510
+
511
+ declare namespace ZipFileTree {
512
+ export {
513
+ ZipFileTreeAccessors,
514
+ ZipFileItem,
515
+ ZipDirectoryItem
516
+ }
517
+ }
518
+ export { ZipFileTree }
519
+
520
+ /**
521
+ * File tree accessors for ZIP archives.
522
+ * @public
523
+ */
524
+ declare class ZipFileTreeAccessors implements FileTree.IFileTreeAccessors {
525
+ /**
526
+ * The unzipped file data.
527
+ */
528
+ private readonly _files;
529
+ /**
530
+ * Optional prefix to prepend to paths.
531
+ */
532
+ private readonly _prefix;
533
+ /**
534
+ * Cache of all items in the ZIP for efficient lookups.
535
+ */
536
+ private readonly _itemCache;
537
+ /**
538
+ * Constructor for ZipFileTreeAccessors.
539
+ * @param files - The unzipped file data from fflate.
540
+ * @param prefix - Optional prefix to prepend to paths.
541
+ */
542
+ private constructor();
543
+ /**
544
+ * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).
545
+ * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.
546
+ * @param prefix - Optional prefix to prepend to paths.
547
+ * @returns Result containing the ZipFileTreeAccessors instance.
548
+ */
549
+ static fromBuffer(zipBuffer: ArrayBuffer | Uint8Array, prefix?: string): Result<ZipFileTreeAccessors>;
550
+ /**
551
+ * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).
552
+ * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.
553
+ * @param prefix - Optional prefix to prepend to paths.
554
+ * @returns Promise containing Result with the ZipFileTreeAccessors instance.
555
+ */
556
+ static fromBufferAsync(zipBuffer: ArrayBuffer | Uint8Array, prefix?: string): Promise<Result<ZipFileTreeAccessors>>;
557
+ /**
558
+ * Creates a new ZipFileTreeAccessors instance from a File object (browser environment).
559
+ * @param file - The File object containing ZIP data.
560
+ * @param prefix - Optional prefix to prepend to paths.
561
+ * @returns Result containing the ZipFileTreeAccessors instance.
562
+ */
563
+ static fromFile(file: File, prefix?: string): Promise<Result<ZipFileTreeAccessors>>;
564
+ /**
565
+ * Builds the cache of all items in the ZIP archive.
566
+ */
567
+ private _buildItemCache;
568
+ /**
569
+ * Resolves paths to an absolute path.
570
+ */
571
+ resolveAbsolutePath(...paths: string[]): string;
572
+ /**
573
+ * Gets the extension of a path.
574
+ */
575
+ getExtension(path: string): string;
576
+ /**
577
+ * Gets the base name of a path.
578
+ */
579
+ getBaseName(path: string, suffix?: string): string;
580
+ /**
581
+ * Joins paths together.
582
+ */
583
+ joinPaths(...paths: string[]): string;
584
+ /**
585
+ * Gets an item from the file tree.
586
+ */
587
+ getItem(path: string): Result<FileTree.FileTreeItem>;
588
+ /**
589
+ * Gets the contents of a file in the file tree.
590
+ */
591
+ getFileContents(path: string): Result<string>;
592
+ /**
593
+ * Gets the children of a directory in the file tree.
594
+ */
595
+ getChildren(path: string): Result<ReadonlyArray<FileTree.FileTreeItem>>;
596
+ /**
597
+ * Checks if childPath is a direct child of parentPath.
598
+ */
599
+ private _isDirectChild;
600
+ }
601
+
602
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.52.10"
9
+ }
10
+ ]
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-extras",
3
- "version": "5.0.0-24",
3
+ "version": "5.0.0-25",
4
4
  "description": "Assorted Typescript Utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-extras.d.ts",
@@ -45,8 +45,8 @@
45
45
  "@types/heft-jest": "1.0.6",
46
46
  "@rushstack/heft-jest-plugin": "0.16.12",
47
47
  "eslint-plugin-tsdoc": "~0.4.0",
48
- "@fgv/ts-utils": "5.0.0-24",
49
- "@fgv/ts-utils-jest": "5.0.0-24"
48
+ "@fgv/ts-utils": "5.0.0-25",
49
+ "@fgv/ts-utils-jest": "5.0.0-25"
50
50
  },
51
51
  "dependencies": {
52
52
  "luxon": "^3.7.1",
@@ -55,7 +55,7 @@
55
55
  "fflate": "~0.8.2"
56
56
  },
57
57
  "peerDependencies": {
58
- "@fgv/ts-utils": "5.0.0-24"
58
+ "@fgv/ts-utils": "5.0.0-25"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "heft test --clean",
@@ -1,343 +0,0 @@
1
- /**
2
- * Config file for API Extractor. For more info, please visit: https://api-extractor.com
3
- */
4
- {
5
- "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
6
- /**
7
- * Optionally specifies another JSON config file that this file extends from. This provides a way for
8
- * standard settings to be shared across multiple projects.
9
- *
10
- * If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
11
- * the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
12
- * resolved using NodeJS require().
13
- *
14
- * SUPPORTED TOKENS: none
15
- * DEFAULT VALUE: ""
16
- */
17
- // "extends": "./shared/api-extractor-base.json"
18
- // "extends": "my-package/include/api-extractor-base.json"
19
- /**
20
- * Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
21
- * typically contains the tsconfig.json and package.json config files, but the path is user-defined.
22
- *
23
- * The path is resolved relative to the folder of the config file that contains the setting.
24
- *
25
- * The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
26
- * parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
27
- * that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
28
- * will be reported.
29
- *
30
- * SUPPORTED TOKENS: <lookup>
31
- * DEFAULT VALUE: "<lookup>"
32
- */
33
- "projectFolder": "..",
34
- /**
35
- * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
36
- * analyzes the symbols exported by this module.
37
- *
38
- * The file extension must be ".d.ts" and not ".ts".
39
- *
40
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
41
- * prepend a folder token such as "<projectFolder>".
42
- *
43
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
44
- */
45
- "mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
46
- /**
47
- * A list of NPM package names whose exports should be treated as part of this package.
48
- *
49
- * For example, suppose that Webpack is used to generate a distributed bundle for the project "library1",
50
- * and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part
51
- * of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly
52
- * imports library2. To avoid this, we can specify:
53
- *
54
- * "bundledPackages": [ "library2" ],
55
- *
56
- * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
57
- * local files for library1.
58
- */
59
- "bundledPackages": [],
60
- /**
61
- * Determines how the TypeScript compiler engine will be invoked by API Extractor.
62
- */
63
- "compiler": {
64
- /**
65
- * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
66
- *
67
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
68
- * prepend a folder token such as "<projectFolder>".
69
- *
70
- * Note: This setting will be ignored if "overrideTsconfig" is used.
71
- *
72
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
73
- * DEFAULT VALUE: "<projectFolder>/tsconfig.json"
74
- */
75
- // "tsconfigFilePath": "<projectFolder>/tsconfig.json",
76
- /**
77
- * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
78
- * The object must conform to the TypeScript tsconfig schema:
79
- *
80
- * http://json.schemastore.org/tsconfig
81
- *
82
- * If omitted, then the tsconfig.json file will be read from the "projectFolder".
83
- *
84
- * DEFAULT VALUE: no overrideTsconfig section
85
- */
86
- // "overrideTsconfig": {
87
- // . . .
88
- // }
89
- /**
90
- * This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
91
- * and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when
92
- * dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses
93
- * for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck.
94
- *
95
- * DEFAULT VALUE: false
96
- */
97
- // "skipLibCheck": true,
98
- },
99
- /**
100
- * Configures how the API report file (*.api.md) will be generated.
101
- */
102
- "apiReport": {
103
- /**
104
- * (REQUIRED) Whether to generate an API report.
105
- */
106
- "enabled": true
107
- /**
108
- * The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
109
- * a full file path.
110
- *
111
- * The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/".
112
- *
113
- * SUPPORTED TOKENS: <packageName>, <unscopedPackageName>
114
- * DEFAULT VALUE: "<unscopedPackageName>.api.md"
115
- */
116
- // "reportFileName": "<unscopedPackageName>.api.md",
117
- /**
118
- * Specifies the folder where the API report file is written. The file name portion is determined by
119
- * the "reportFileName" setting.
120
- *
121
- * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
122
- * e.g. for an API review.
123
- *
124
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
125
- * prepend a folder token such as "<projectFolder>".
126
- *
127
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
128
- * DEFAULT VALUE: "<projectFolder>/etc/"
129
- */
130
- // "reportFolder": "<projectFolder>/etc/",
131
- /**
132
- * Specifies the folder where the temporary report file is written. The file name portion is determined by
133
- * the "reportFileName" setting.
134
- *
135
- * After the temporary file is written to disk, it is compared with the file in the "reportFolder".
136
- * If they are different, a production build will fail.
137
- *
138
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
139
- * prepend a folder token such as "<projectFolder>".
140
- *
141
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
142
- * DEFAULT VALUE: "<projectFolder>/temp/"
143
- */
144
- // "reportTempFolder": "<projectFolder>/temp/"
145
- },
146
- /**
147
- * Configures how the doc model file (*.api.json) will be generated.
148
- */
149
- "docModel": {
150
- /**
151
- * (REQUIRED) Whether to generate a doc model file.
152
- */
153
- "enabled": true
154
- /**
155
- * The output path for the doc model file. The file extension should be ".api.json".
156
- *
157
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
158
- * prepend a folder token such as "<projectFolder>".
159
- *
160
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
161
- * DEFAULT VALUE: "<projectFolder>/temp/<unscopedPackageName>.api.json"
162
- */
163
- // "apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json"
164
- },
165
- /**
166
- * Configures how the .d.ts rollup file will be generated.
167
- */
168
- "dtsRollup": {
169
- /**
170
- * (REQUIRED) Whether to generate the .d.ts rollup file.
171
- */
172
- "enabled": true
173
- /**
174
- * Specifies the output path for a .d.ts rollup file to be generated without any trimming.
175
- * This file will include all declarations that are exported by the main entry point.
176
- *
177
- * If the path is an empty string, then this file will not be written.
178
- *
179
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
180
- * prepend a folder token such as "<projectFolder>".
181
- *
182
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
183
- * DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
184
- */
185
- // "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
186
- /**
187
- * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
188
- * This file will include only declarations that are marked as "@public" or "@beta".
189
- *
190
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
191
- * prepend a folder token such as "<projectFolder>".
192
- *
193
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
194
- * DEFAULT VALUE: ""
195
- */
196
- // "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
197
- /**
198
- * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
199
- * This file will include only declarations that are marked as "@public".
200
- *
201
- * If the path is an empty string, then this file will not be written.
202
- *
203
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
204
- * prepend a folder token such as "<projectFolder>".
205
- *
206
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
207
- * DEFAULT VALUE: ""
208
- */
209
- // "publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts",
210
- /**
211
- * When a declaration is trimmed, by default it will be replaced by a code comment such as
212
- * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
213
- * declaration completely.
214
- *
215
- * DEFAULT VALUE: false
216
- */
217
- // "omitTrimmingComments": true
218
- },
219
- /**
220
- * Configures how the tsdoc-metadata.json file will be generated.
221
- */
222
- "tsdocMetadata": {
223
- /**
224
- * Whether to generate the tsdoc-metadata.json file.
225
- *
226
- * DEFAULT VALUE: true
227
- */
228
- // "enabled": true,
229
- /**
230
- * Specifies where the TSDoc metadata file should be written.
231
- *
232
- * The path is resolved relative to the folder of the config file that contains the setting; to change this,
233
- * prepend a folder token such as "<projectFolder>".
234
- *
235
- * The default value is "<lookup>", which causes the path to be automatically inferred from the "tsdocMetadata",
236
- * "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup
237
- * falls back to "tsdoc-metadata.json" in the package folder.
238
- *
239
- * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
240
- * DEFAULT VALUE: "<lookup>"
241
- */
242
- // "tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json"
243
- },
244
- /**
245
- * Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
246
- * will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
247
- * To use the OS's default newline kind, specify "os".
248
- *
249
- * DEFAULT VALUE: "crlf"
250
- */
251
- // "newlineKind": "crlf",
252
- /**
253
- * Configures how API Extractor reports error and warning messages produced during analysis.
254
- *
255
- * There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
256
- */
257
- "messages": {
258
- /**
259
- * Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
260
- * the input .d.ts files.
261
- *
262
- * TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
263
- *
264
- * DEFAULT VALUE: A single "default" entry with logLevel=warning.
265
- */
266
- "compilerMessageReporting": {
267
- /**
268
- * Configures the default routing for messages that don't match an explicit rule in this table.
269
- */
270
- "default": {
271
- /**
272
- * Specifies whether the message should be written to the the tool's output log. Note that
273
- * the "addToApiReportFile" property may supersede this option.
274
- *
275
- * Possible values: "error", "warning", "none"
276
- *
277
- * Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
278
- * and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
279
- * the "--local" option), the warning is displayed but the build will not fail.
280
- *
281
- * DEFAULT VALUE: "warning"
282
- */
283
- "logLevel": "warning"
284
- /**
285
- * When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
286
- * then the message will be written inside that file; otherwise, the message is instead logged according to
287
- * the "logLevel" option.
288
- *
289
- * DEFAULT VALUE: false
290
- */
291
- // "addToApiReportFile": false
292
- }
293
- // "TS2551": {
294
- // "logLevel": "warning",
295
- // "addToApiReportFile": true
296
- // },
297
- //
298
- // . . .
299
- },
300
- /**
301
- * Configures handling of messages reported by API Extractor during its analysis.
302
- *
303
- * API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
304
- *
305
- * DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
306
- */
307
- "extractorMessageReporting": {
308
- "default": {
309
- "logLevel": "warning"
310
- // "addToApiReportFile": false
311
- },
312
- "ae-unresolved-link": {
313
- "logLevel": "none",
314
- "addToApiReportFile": true
315
- }
316
- // "ae-extra-release-tag": {
317
- // "logLevel": "warning",
318
- // "addToApiReportFile": true
319
- // },
320
- //
321
- // . . .
322
- },
323
- /**
324
- * Configures handling of messages reported by the TSDoc parser when analyzing code comments.
325
- *
326
- * TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text"
327
- *
328
- * DEFAULT VALUE: A single "default" entry with logLevel=warning.
329
- */
330
- "tsdocMessageReporting": {
331
- "default": {
332
- "logLevel": "warning"
333
- // "addToApiReportFile": false
334
- }
335
- // "tsdoc-link-tag-unescaped-text": {
336
- // "logLevel": "warning",
337
- // "addToApiReportFile": true
338
- // },
339
- //
340
- // . . .
341
- }
342
- }
343
- }
package/config/rig.json DELETED
@@ -1,16 +0,0 @@
1
- // The "rig.json" file directs tools to look for their config files in an external package.
2
- // Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
3
- {
4
- "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
5
- /**
6
- * (Required) The name of the rig package to inherit from.
7
- * It should be an NPM package name with the "-rig" suffix.
8
- */
9
- "rigPackageName": "@rushstack/heft-node-rig"
10
- /**
11
- * (Optional) Selects a config profile from the rig package. The name must consist of
12
- * lowercase alphanumeric words separated by hyphens, for example "sample-profile".
13
- * If omitted, then the "default" profile will be used."
14
- */
15
- // "rigProfile": "your-profile-name"
16
- }