@fgv/ts-json-base 5.0.0-24 → 5.0.0-26

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,458 @@
1
+ import { Converter } from '@fgv/ts-utils';
2
+ import { Result } from '@fgv/ts-utils';
3
+ import { Validator } from '@fgv/ts-utils';
4
+
5
+ /**
6
+ * Identifies whether some `unknown` value is a {@link JsonPrimitive | primitive},
7
+ * {@link JsonObject | object} or {@link JsonArray | array}. Fails for any value
8
+ * that cannot be converted to JSON (e.g. a function) _but_ this is a shallow test -
9
+ * it does not test the properties of an object or elements in an array.
10
+ * @param from - The `unknown` value to be tested
11
+ * @public
12
+ */
13
+ export declare function classifyJsonValue(from: unknown): Result<JsonValueType>;
14
+
15
+ declare namespace Converters {
16
+ export {
17
+ IJsonConverterContext,
18
+ jsonPrimitive,
19
+ jsonObject,
20
+ jsonArray,
21
+ jsonValue
22
+ }
23
+ }
24
+ export { Converters }
25
+
26
+ /**
27
+ * Reads all JSON files from a directory and apply a supplied converter.
28
+ * @param srcPath - The path of the folder to be read.
29
+ * @param options - {@link JsonFile.IJsonFsDirectoryOptions | Options} to control
30
+ * conversion and filtering
31
+ * @public
32
+ */
33
+ declare function convertJsonDirectorySync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryOptions<T, TC>): Result<IReadDirectoryItem<T>[]>;
34
+
35
+ /**
36
+ * Reads and converts all JSON files from a directory, returning a
37
+ * `Map<string, T>` indexed by file base name (i.e. minus the extension)
38
+ * with an optional name transformation applied if present.
39
+ * @param srcPath - The path of the folder to be read.
40
+ * @param options - {@link JsonFile.IJsonFsDirectoryToMapOptions | Options} to control conversion,
41
+ * filtering and naming.
42
+ * @public
43
+ */
44
+ declare function convertJsonDirectoryToMapSync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryToMapOptions<T, TC>): Result<Map<string, T>>;
45
+
46
+ /**
47
+ * Read a JSON file and apply a supplied converter.
48
+ * @param srcPath - Path of the file to read.
49
+ * @param converter - `Converter` used to convert the file contents
50
+ * @returns `Success` with a result of type `<T>`, or `Failure`* with a message if an error occurs.
51
+ * @public
52
+ */
53
+ declare function convertJsonFileSync<T, TC = unknown>(srcPath: string, converter: Converter<T, TC>): Result<T>;
54
+
55
+ /**
56
+ * @public
57
+ */
58
+ declare const DefaultJsonFsHelper: JsonFsHelper;
59
+
60
+ /**
61
+ * Default configuration for {@link JsonFile.JsonFsHelper | JsonFsHelper}.
62
+ * @public
63
+ */
64
+ declare const DefaultJsonFsHelperConfig: IJsonFsHelperConfig;
65
+
66
+ /**
67
+ * @public
68
+ */
69
+ declare const DefaultJsonLike: IJsonLike;
70
+
71
+ /**
72
+ * Conversion context for JSON converters.
73
+ * @public
74
+ */
75
+ declare interface IJsonConverterContext {
76
+ ignoreUndefinedProperties?: boolean;
77
+ }
78
+
79
+ /**
80
+ * Options for directory conversion.
81
+ * TODO: add filtering, allowed and excluded.
82
+ * @public
83
+ */
84
+ declare interface IJsonFsDirectoryOptions<T, TC = unknown> {
85
+ /**
86
+ * The converter used to convert incoming JSON objects.
87
+ */
88
+ converter: Converter<T, TC> | Validator<T, TC>;
89
+ /**
90
+ * Filter applied to items in the directory
91
+ */
92
+ files?: RegExp[];
93
+ }
94
+
95
+ /**
96
+ * Options controlling conversion of a directory to a `Map`.
97
+ * @public
98
+ */
99
+ declare interface IJsonFsDirectoryToMapOptions<T, TC = unknown> extends IJsonFsDirectoryOptions<T, TC> {
100
+ transformName?: ItemNameTransformFunction<T>;
101
+ }
102
+
103
+ /**
104
+ * Configuration for {@link JsonFile.JsonFsHelper | JsonFsHelper}.
105
+ * @public
106
+ */
107
+ declare interface IJsonFsHelperConfig {
108
+ json: IJsonLike;
109
+ allowUndefinedWrite: boolean;
110
+ defaultFiles: RegExp[];
111
+ }
112
+
113
+ /**
114
+ * @public
115
+ */
116
+ declare interface IJsonLike {
117
+ parse(text: string, reviver?: JsonReviver, options?: unknown): JsonValue | undefined;
118
+ stringify(value: JsonValue, replacer?: JsonReplacer, space?: string | number): string | undefined;
119
+ }
120
+
121
+ /**
122
+ * Validation context for in-place JSON validators.
123
+ * @public
124
+ */
125
+ declare interface IJsonValidatorContext {
126
+ ignoreUndefinedProperties?: boolean;
127
+ }
128
+
129
+ /**
130
+ * Return value for one item in a directory conversion.
131
+ * @public
132
+ */
133
+ declare interface IReadDirectoryItem<T> {
134
+ /**
135
+ * Relative name of the file that was processed
136
+ */
137
+ filename: string;
138
+ /**
139
+ * The payload of the file.
140
+ */
141
+ item: T;
142
+ }
143
+
144
+ /**
145
+ * Test if an `unknown` is potentially a {@link JsonArray | JsonArray}.
146
+ * @param from - The `unknown` to be tested.
147
+ * @returns `true` if the supplied parameter is an array object,
148
+ * `false` otherwise.
149
+ * @public
150
+ */
151
+ export declare function isJsonArray(from: unknown): from is JsonArray;
152
+
153
+ /**
154
+ * Test if an `unknown` is potentially a {@link JsonObject | JsonObject}.
155
+ * @param from - The `unknown` to be tested.
156
+ * @returns `true` if the supplied parameter is a non-array, non-special object,
157
+ * `false` otherwise.
158
+ * @public
159
+ */
160
+ export declare function isJsonObject(from: unknown): from is JsonObject;
161
+
162
+ /**
163
+ * Test if an `unknown` is a {@link JsonValue | JsonValue}.
164
+ * @param from - The `unknown` to be tested
165
+ * @returns `true` if the supplied parameter is a valid {@link JsonPrimitive | JsonPrimitive},
166
+ * `false` otherwise.
167
+ * @public
168
+ */
169
+ export declare function isJsonPrimitive(from: unknown): from is JsonPrimitive;
170
+
171
+ /**
172
+ * Function to transform the name of a some entity, given an original name
173
+ * and the contents of the entity.
174
+ * @public
175
+ */
176
+ declare type ItemNameTransformFunction<T> = (name: string, item: T) => Result<string>;
177
+
178
+ /**
179
+ * A {@link JsonArray | JsonArray} is an array containing only valid {@link JsonValue | JsonValues}.
180
+ * @public
181
+ */
182
+ export declare interface JsonArray extends Array<JsonValue> {
183
+ }
184
+
185
+ /**
186
+ * An copying converter which converts a supplied `unknown` value to
187
+ * a valid {@link JsonArray | JsonArray}. Fails by default if any properties or array elements
188
+ * are `undefined` - this default behavior can be overridden by supplying an appropriate
189
+ * {@link Converters.IJsonConverterContext | context} at runtime.
190
+ *
191
+ * Guaranteed to return a new array.
192
+ * @public
193
+ */
194
+ declare const jsonArray: Converter<JsonArray, IJsonConverterContext>;
195
+
196
+ /**
197
+ * An in-place validator which validates that a supplied `unknown` value is
198
+ * a valid {@link JsonArray | JsonArray}. Fails by default if any properties or array elements
199
+ * are `undefined` - this default behavior can be overridden by supplying an appropriate
200
+ * {@link Validators.IJsonValidatorContext | context} at runtime.
201
+ * @public
202
+ */
203
+ declare const jsonArray_2: Validator<JsonArray, IJsonValidatorContext>;
204
+
205
+ declare namespace JsonFile {
206
+ export {
207
+ readJsonFileSync,
208
+ convertJsonFileSync,
209
+ convertJsonDirectorySync,
210
+ convertJsonDirectoryToMapSync,
211
+ writeJsonFileSync,
212
+ IJsonFsDirectoryOptions,
213
+ IReadDirectoryItem,
214
+ ItemNameTransformFunction,
215
+ IJsonFsDirectoryToMapOptions,
216
+ IJsonFsHelperConfig,
217
+ JsonFsHelperInitOptions,
218
+ DefaultJsonFsHelperConfig,
219
+ JsonFsHelper,
220
+ DefaultJsonFsHelper,
221
+ JsonReviver,
222
+ JsonReplacerFunction,
223
+ JsonReplacerArray,
224
+ JsonReplacer,
225
+ IJsonLike,
226
+ DefaultJsonLike
227
+ }
228
+ }
229
+ export { JsonFile }
230
+
231
+ /**
232
+ * Helper class to simplify common filesystem operations involving JSON (or JSON-like)
233
+ * files.
234
+ * @public
235
+ */
236
+ declare class JsonFsHelper {
237
+ /**
238
+ * Configuration for this {@link JsonFile.JsonFsHelper | JsonFsHelper}.
239
+ */
240
+ readonly config: IJsonFsHelperConfig;
241
+ /**
242
+ * Construct a new {@link JsonFile.JsonFsHelper | JsonFsHelper}.
243
+ * @param json - Optional {@link JsonFile.IJsonLike | IJsonLike} used to process strings
244
+ * and JSON values.
245
+ */
246
+ constructor(init?: JsonFsHelperInitOptions);
247
+ /**
248
+ * Read type-safe JSON from a file.
249
+ * @param srcPath - Path of the file to read
250
+ * @returns `Success` with a {@link JsonValue | JsonValue} or `Failure`
251
+ * with a message if an error occurs.
252
+ */
253
+ readJsonFileSync(srcPath: string): Result<JsonValue>;
254
+ /**
255
+ * Read a JSON file and apply a supplied converter or validator.
256
+ * @param srcPath - Path of the file to read.
257
+ * @param cv - Converter or validator used to process the file.
258
+ * @returns `Success` with a result of type `<T>`, or `Failure`
259
+ * with a message if an error occurs.
260
+ */
261
+ convertJsonFileSync<T, TC = unknown>(srcPath: string, cv: Converter<T, TC> | Validator<T, TC>, context?: TC): Result<T>;
262
+ /**
263
+ * Reads all JSON files from a directory and apply a supplied converter or validator.
264
+ * @param srcPath - The path of the folder to be read.
265
+ * @param options - {@link JsonFile.IJsonFsDirectoryOptions | Options} to control
266
+ * conversion and filtering
267
+ */
268
+ convertJsonDirectorySync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryOptions<T>, context?: TC): Result<IReadDirectoryItem<T>[]>;
269
+ /**
270
+ * Reads and converts or validates all JSON files from a directory, returning a
271
+ * `Map<string, T>` indexed by file base name (i.e. minus the extension)
272
+ * with an optional name transformation applied if present.
273
+ * @param srcPath - The path of the folder to be read.
274
+ * @param options - {@link JsonFile.IJsonFsDirectoryToMapOptions | Options} to control conversion,
275
+ * filtering and naming.
276
+ */
277
+ convertJsonDirectoryToMapSync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryToMapOptions<T, TC>, context?: unknown): Result<Map<string, T>>;
278
+ /**
279
+ * Write type-safe JSON to a file.
280
+ * @param srcPath - Path of the file to write.
281
+ * @param value - The {@link JsonValue | JsonValue} to be written.
282
+ */
283
+ writeJsonFileSync(srcPath: string, value: JsonValue): Result<boolean>;
284
+ protected _pathMatchesOptions<T, TC>(options: IJsonFsDirectoryOptions<T, TC>, path: string): boolean;
285
+ }
286
+
287
+ /**
288
+ * Initialization options for {@link JsonFile.JsonFsHelper | JsonFsHelper}.
289
+ * @public
290
+ */
291
+ declare type JsonFsHelperInitOptions = Partial<IJsonFsHelperConfig>;
292
+
293
+ /**
294
+ * A {@link JsonObject | JsonObject} is a string-keyed object
295
+ * containing only valid {@link JsonValue | JSON values}.
296
+ * @public
297
+ */
298
+ export declare interface JsonObject {
299
+ [key: string]: JsonValue;
300
+ }
301
+
302
+ /**
303
+ * An copying converter which converts a supplied `unknown` value into
304
+ * a valid {@link JsonObject | JsonObject}. Fails by default if any properties or array elements
305
+ * are `undefined` - this default behavior can be overridden by supplying an appropriate
306
+ * {@link Converters.IJsonConverterContext | context} at runtime.
307
+ *
308
+ * Guaranteed to return a new object.
309
+ * @public
310
+ */
311
+ declare const jsonObject: Converter<JsonObject, IJsonConverterContext>;
312
+
313
+ /**
314
+ * An in-place validator which validates that a supplied `unknown` value is
315
+ * a valid {@link JsonObject | JsonObject}. Fails by default if any properties or array elements
316
+ * are `undefined` - this default behavior can be overridden by supplying an appropriate
317
+ * {@link Validators.IJsonValidatorContext | context} at runtime.
318
+ * @public
319
+ */
320
+ declare const jsonObject_2: Validator<JsonObject, IJsonValidatorContext>;
321
+
322
+ /**
323
+ * Primitive (terminal) values allowed in by JSON.
324
+ * @public
325
+ */
326
+ export declare type JsonPrimitive = boolean | number | string | null;
327
+
328
+ /**
329
+ * An converter which converts a supplied `unknown` value to a valid {@link JsonPrimitive | JsonPrimitive}.
330
+ * @public
331
+ */
332
+ declare const jsonPrimitive: Converter<JsonPrimitive, IJsonConverterContext>;
333
+
334
+ /**
335
+ * An in-place validator which validates that a supplied `unknown` value is
336
+ * a valid {@link JsonPrimitive | JsonPrimitive}.
337
+ * @public
338
+ */
339
+ declare const jsonPrimitive_2: Validator<JsonPrimitive, IJsonValidatorContext>;
340
+
341
+ /**
342
+ * @public
343
+ */
344
+ declare type JsonReplacer = JsonReplacerFunction | JsonReplacerArray;
345
+
346
+ /**
347
+ * @public
348
+ */
349
+ declare type JsonReplacerArray = (string | number)[];
350
+
351
+ /**
352
+ * @public
353
+ */
354
+ declare type JsonReplacerFunction = (key: string, value: JsonValue) => JsonValue;
355
+
356
+ /**
357
+ * @public
358
+ */
359
+ declare type JsonReviver = (key: string, value: JsonValue) => JsonValue;
360
+
361
+ /**
362
+ * A {@link JsonValue | JsonValue} is one of: a {@link JsonPrimitive | JsonPrimitive},
363
+ * a {@link JsonObject | JsonObject} or an {@link JsonArray | JsonArray}.
364
+ * @public
365
+ */
366
+ export declare type JsonValue = JsonPrimitive | JsonObject | JsonArray;
367
+
368
+ /**
369
+ * An copying converter which converts a supplied `unknown` value to a
370
+ * valid {@link JsonValue | JsonValue}. Fails by default if any properties or array elements
371
+ * are `undefined` - this default behavior can be overridden by supplying an appropriate
372
+ * {@link Converters.IJsonConverterContext | context} at runtime.
373
+ * @public
374
+ */
375
+ declare const jsonValue: Converter<JsonValue, IJsonConverterContext>;
376
+
377
+ /**
378
+ * An in-place validator which validates that a supplied `unknown` value is
379
+ * a valid {@link JsonValue | JsonValue}. Fails by default if any properties or array elements
380
+ * are `undefined` - this default behavior can be overridden by supplying an appropriate
381
+ * {@link Validators.IJsonValidatorContext | context} at runtime.
382
+ * @public
383
+ */
384
+ declare const jsonValue_2: Validator<JsonValue, IJsonValidatorContext>;
385
+
386
+ /**
387
+ * Classes of {@link JsonValue | JsonValue}.
388
+ * @public
389
+ */
390
+ export declare type JsonValueType = 'primitive' | 'object' | 'array';
391
+
392
+ /**
393
+ * Picks a nested {@link JsonObject | JsonObject} from a supplied
394
+ * {@link JsonObject | JsonObject}.
395
+ * @param src - The {@link JsonObject | object} from which the field is
396
+ * to be picked.
397
+ * @param path - Dot-separated path of the member to be picked.
398
+ * @returns `Success` with the property if the path is valid and the value
399
+ * is an object. Returns `Failure` with details if an error occurs.
400
+ * @public
401
+ */
402
+ export declare function pickJsonObject(src: JsonObject, path: string): Result<JsonObject>;
403
+
404
+ /**
405
+ * Picks a nested field from a supplied {@link JsonObject | JsonObject}.
406
+ * @param src - The {@link JsonObject | object} from which the field is to be picked.
407
+ * @param path - Dot-separated path of the member to be picked.
408
+ * @returns `Success` with the property if the path is valid, `Failure`
409
+ * with an error message otherwise.
410
+ * @public
411
+ */
412
+ export declare function pickJsonValue(src: JsonObject, path: string): Result<JsonValue>;
413
+
414
+ /**
415
+ * {@inheritdoc JsonFile.JsonFsHelper.readJsonFileSync}
416
+ * @public
417
+ */
418
+ declare function readJsonFileSync(srcPath: string): Result<JsonValue>;
419
+
420
+ /**
421
+ * "Sanitizes" an `unknown` by stringifying and then parsing it. Guarantees a
422
+ * valid {@link JsonValue | JsonValue} but is not idempotent and gives no guarantees
423
+ * about fidelity. Fails if the supplied value cannot be stringified as Json.
424
+ * @param from - The `unknown` to be sanitized.
425
+ * @returns `Success` with a {@link JsonValue | JsonValue} if conversion succeeds,
426
+ * `Failure` with details if an error occurs.
427
+ * @public
428
+ */
429
+ export declare function sanitizeJson(from: unknown): Result<JsonValue>;
430
+
431
+ /**
432
+ * Sanitizes some value using JSON stringification and parsing, returning an
433
+ * returning a matching strongly-typed value.
434
+ * @param from - The value to be sanitized.
435
+ * @returns `Success` with a {@link JsonObject | JsonObject} if conversion succeeds,
436
+ * `Failure` with details if an error occurs.
437
+ * @public
438
+ */
439
+ export declare function sanitizeJsonObject<T>(from: T): Result<T>;
440
+
441
+ declare namespace Validators {
442
+ export {
443
+ IJsonValidatorContext,
444
+ jsonPrimitive_2 as jsonPrimitive,
445
+ jsonObject_2 as jsonObject,
446
+ jsonArray_2 as jsonArray,
447
+ jsonValue_2 as jsonValue
448
+ }
449
+ }
450
+ export { Validators }
451
+
452
+ /**
453
+ * {@inheritDoc JsonFile.JsonFsHelper.writeJsonFileSync}
454
+ * @public
455
+ */
456
+ declare function writeJsonFileSync(srcPath: string, value: JsonValue): Result<boolean>;
457
+
458
+ 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.11"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,16 @@
1
+ // ESLint 9 flat config
2
+ const nodeProfile = require('@rushstack/eslint-config/flat/profile/node');
3
+ const packletsPlugin = require('@rushstack/eslint-config/flat/mixins/packlets');
4
+ const tsdocPlugin = require('@rushstack/eslint-config/flat/mixins/tsdoc');
5
+
6
+ module.exports = [
7
+ ...nodeProfile,
8
+ packletsPlugin,
9
+ ...tsdocPlugin,
10
+ {
11
+ // Override specific rules if needed
12
+ rules: {
13
+ '@rushstack/packlets/mechanics': 'warn'
14
+ }
15
+ }
16
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-json-base",
3
- "version": "5.0.0-24",
3
+ "version": "5.0.0-26",
4
4
  "description": "Typescript types and basic functions for working with json",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-json-base.d.ts",
@@ -18,19 +18,19 @@
18
18
  "devDependencies": {
19
19
  "@types/jest": "^29.5.14",
20
20
  "@types/node": "^20.14.9",
21
- "@typescript-eslint/eslint-plugin": "^7.14.1",
22
- "@typescript-eslint/parser": "^7.14.1",
23
- "eslint": "^8.57.0",
21
+ "@typescript-eslint/eslint-plugin": "^8.42.0",
22
+ "@typescript-eslint/parser": "^8.42.0",
23
+ "eslint": "^9.35.0",
24
24
  "eslint-plugin-import": "^2.32.0",
25
25
  "eslint-plugin-node": "^11.1.0",
26
- "eslint-plugin-promise": "^6.2.0",
26
+ "eslint-plugin-promise": "^7.2.1",
27
27
  "jest": "^29.7.0",
28
28
  "jest-extended": "^4.0.2",
29
- "rimraf": "^5.0.7",
29
+ "rimraf": "^6.0.1",
30
30
  "ts-jest": "^29.4.1",
31
31
  "ts-node": "^10.9.2",
32
32
  "typescript": "5.8.3",
33
- "eslint-plugin-n": "^16.6.2",
33
+ "eslint-plugin-n": "^17.21.3",
34
34
  "@rushstack/heft-node-rig": "2.9.4",
35
35
  "@rushstack/heft": "0.74.3",
36
36
  "@rushstack/heft-jest-plugin": "0.16.12",
@@ -39,12 +39,12 @@
39
39
  "@rushstack/eslint-patch": "~1.12.0",
40
40
  "@rushstack/eslint-config": "4.4.0",
41
41
  "eslint-plugin-tsdoc": "~0.4.0",
42
- "@fgv/ts-utils": "5.0.0-24",
43
- "@fgv/ts-utils-jest": "5.0.0-24",
44
- "@fgv/ts-extras": "5.0.0-24"
42
+ "@fgv/ts-utils": "5.0.0-26",
43
+ "@fgv/ts-extras": "5.0.0-26",
44
+ "@fgv/ts-utils-jest": "5.0.0-26"
45
45
  },
46
46
  "peerDependencies": {
47
- "@fgv/ts-utils": "5.0.0-24"
47
+ "@fgv/ts-utils": "5.0.0-26"
48
48
  },
49
49
  "scripts": {
50
50
  "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
- }