@fgv/ts-json-base 5.0.0-23 → 5.0.0-24
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.
- package/CHANGELOG.json +0 -18
- package/package.json +10 -10
- package/.vscode/launch.json +0 -16
- package/.vscode/settings.json +0 -33
- package/dist/ts-json-base.d.ts +0 -458
- package/dist/tsdoc-metadata.json +0 -11
- package/lib/test/unit/common.test.d.ts +0 -2
- package/lib/test/unit/converters.test.d.ts +0 -2
- package/lib/test/unit/data/file/bad/bad3.json +0 -3
- package/lib/test/unit/data/file/bad/thing1.json +0 -4
- package/lib/test/unit/data/file/bad/thing2.json +0 -3
- package/lib/test/unit/data/file/good/thing1.json +0 -4
- package/lib/test/unit/data/file/good/thing2.json +0 -3
- package/lib/test/unit/file.test.d.ts +0 -2
- package/lib/test/unit/jsonFsHelper.test.d.ts +0 -2
- package/lib/test/unit/validators.test.d.ts +0 -2
package/CHANGELOG.json
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-json-base",
|
|
3
3
|
"entries": [
|
|
4
|
-
{
|
|
5
|
-
"version": "5.0.0",
|
|
6
|
-
"tag": "@fgv/ts-json-base_v5.0.0",
|
|
7
|
-
"date": "Thu, 17 Jul 2025 00:13:24 GMT",
|
|
8
|
-
"comments": {
|
|
9
|
-
"none": [
|
|
10
|
-
{
|
|
11
|
-
"comment": "add sanitizeJsonObject"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"comment": "upgrade dependencies"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"comment": "bump version"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
4
|
{
|
|
23
5
|
"version": "4.6.0",
|
|
24
6
|
"tag": "@fgv/ts-json-base_v4.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-json-base",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-24",
|
|
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",
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"rimraf": "^5.0.7",
|
|
30
30
|
"ts-jest": "^29.4.1",
|
|
31
31
|
"ts-node": "^10.9.2",
|
|
32
|
-
"typescript": "
|
|
32
|
+
"typescript": "5.8.3",
|
|
33
33
|
"eslint-plugin-n": "^16.6.2",
|
|
34
|
-
"@rushstack/heft-node-rig": "
|
|
35
|
-
"@rushstack/heft": "
|
|
36
|
-
"heft-jest": "
|
|
34
|
+
"@rushstack/heft-node-rig": "2.9.4",
|
|
35
|
+
"@rushstack/heft": "0.74.3",
|
|
36
|
+
"@rushstack/heft-jest-plugin": "0.16.12",
|
|
37
37
|
"@types/heft-jest": "1.0.6",
|
|
38
38
|
"@microsoft/api-documenter": "^7.26.31",
|
|
39
39
|
"@rushstack/eslint-patch": "~1.12.0",
|
|
40
|
-
"@rushstack/eslint-config": "
|
|
40
|
+
"@rushstack/eslint-config": "4.4.0",
|
|
41
41
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
42
|
-
"@fgv/ts-utils": "5.0.0-
|
|
43
|
-
"@fgv/ts-utils-jest": "5.0.0-
|
|
44
|
-
"@fgv/ts-extras": "5.0.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"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@fgv/ts-utils": "5.0.0-
|
|
47
|
+
"@fgv/ts-utils": "5.0.0-24"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "heft test --clean",
|
package/.vscode/launch.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"type": "node",
|
|
9
|
-
"request": "launch",
|
|
10
|
-
"name": "Launch Program",
|
|
11
|
-
"skipFiles": ["<node_internals>/**"],
|
|
12
|
-
"program": "${workspaceFolder}/lib/index.js",
|
|
13
|
-
"outFiles": ["${workspaceFolder}/**/*.js"]
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
package/.vscode/settings.json
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"typescript.tsdk": "node_modules\\typescript\\lib",
|
|
3
|
-
"search.exclude": {
|
|
4
|
-
"**/boneyard": true
|
|
5
|
-
},
|
|
6
|
-
"files.exclude": {
|
|
7
|
-
"**/boneyard/**/*.ts": true
|
|
8
|
-
},
|
|
9
|
-
"cSpell.words": [
|
|
10
|
-
"badp",
|
|
11
|
-
"dflt",
|
|
12
|
-
"Eulers",
|
|
13
|
-
"fixlint",
|
|
14
|
-
"furst",
|
|
15
|
-
"luxon",
|
|
16
|
-
"multivalue",
|
|
17
|
-
"nums",
|
|
18
|
-
"oopsy",
|
|
19
|
-
"packlets",
|
|
20
|
-
"papaparse",
|
|
21
|
-
"prefixp",
|
|
22
|
-
"rtrn",
|
|
23
|
-
"rushstack",
|
|
24
|
-
"TCONV",
|
|
25
|
-
"TDEST",
|
|
26
|
-
"TELEM",
|
|
27
|
-
"templating",
|
|
28
|
-
"TSRC",
|
|
29
|
-
"TTOELEM",
|
|
30
|
-
"xyzzy"
|
|
31
|
-
],
|
|
32
|
-
"CodeGPT.apiKey": "CodeGPT Plus Beta"
|
|
33
|
-
}
|
package/dist/ts-json-base.d.ts
DELETED
|
@@ -1,458 +0,0 @@
|
|
|
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 { }
|
package/dist/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|